home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / bn_bignet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  81.4 KB  |  2,591 lines

  1. /*****************************************************************************
  2.   FILE           : bn_bignet.c
  3.   SHORTNAME      : bn_bignet
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : Creates the BIGNET-window. 
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Michael Schmalzl  
  10.   DATE           : 1.4.1990
  11.  
  12.   CHANGED BY     : Sven Doering, Kai-Uwe Herrmann
  13.   IDENTIFICATION : @(#)bn_bignet.c    1.15 3/2/94
  14.   SCCS VERSION   : 1.15
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20.  
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <X11/Xlib.h>
  24. #include <X11/Xutil.h>
  25. #include <X11/Xos.h>
  26. #include <X11/cursorfont.h>
  27. #include <X11/Intrinsic.h>
  28. #include <X11/StringDefs.h>
  29. #include <X11/Shell.h>
  30. #include <X11/Xaw/Box.h>
  31. #include <X11/Xaw/Simple.h>
  32. #include <X11/Xaw/Grip.h>
  33. #include <X11/Xaw/Form.h>
  34. #include <X11/Xaw/SmeBSB.h>
  35. #include <X11/Xaw/SmeLine.h>
  36. #include <X11/Xaw/Viewport.h>
  37. #include <X11/Xaw/Label.h>
  38. #include <X11/Xaw/Toggle.h>
  39. #include <X11/Xaw/Command.h>
  40. #include <X11/Xaw/Cardinals.h>
  41. #include <X11/Xaw/AsciiText.h>
  42. #include <X11/Xaw/Scrollbar.h>
  43.  
  44. #include "ui.h"
  45. #include "glob_typ.h"
  46. #include "kr_ui.h"
  47. #include "ui_mainP.h"
  48. #include "ui_confirmer.h"
  49. #include "ui_textP.h"
  50. #include "ui_utilP.h"
  51. #include "ui_netUpdate.h"
  52. #include "ui_status.h"
  53. #include "ui_xWidgets.h"
  54. #include "ui_fileP.h"
  55. #include "ui_display.h"
  56. #include "ui_event.h"
  57. #include "ui_selection.h"
  58. #include "bn_basics.h"
  59.  
  60. #include "bn_bignet.ph"
  61.  
  62.  
  63.  
  64. /*************************************************************************
  65.  
  66.      File bn_cretae_net 
  67.  
  68. ***************************************************************************/
  69.  
  70. /*****************************************************************************
  71.   FUNCTION : bn_createPlanePanel
  72.  
  73.   PURPOSE  : creates the plane panel, which is part of the bignet-window
  74.   NOTES    :
  75.   RETURNS  :
  76.   UPDATE   : 20.12.1991
  77. ******************************************************************************/
  78.  
  79. static void bn_createPlanePannel (Widget parent)
  80.  
  81. {
  82.     Widget pannel;
  83.     Widget plane_edit,current_plane;
  84.     Widget plane_enter,plane_delete,plane_insert,plane_overwrite,plane_to_edit,type,pos;
  85.     Widget plane_first,plane_last,plane_prev,plane_next;
  86.     Widget       dummy;
  87.     Arg          arg[25];
  88.     Cardinal     n;
  89.     int colom1 = 25, colom2 = 13, colom3 = 10;
  90.     
  91.     n = 0;  
  92.  
  93.     pannel = XtCreateManagedWidget ("pannel", formWidgetClass, parent, arg, n);
  94.  
  95.     z1s1 = ui_xCreateLabelItem ("           Plane           ", pannel, colom1 * bn_fontWidth, NULL, NULL); 
  96.     z1s2 = ui_xCreateLabelItem ("Current Plane  ", pannel, colom2 * bn_fontWidth, z1s1, NULL); 
  97.     z1s3 = ui_xCreateLabelItem ("Edit Plane  ", pannel, colom3 * bn_fontWidth, z1s2, NULL); 
  98.  
  99.     z2s1   = ui_xCreateLabelItem ("Plane: ", pannel, colom1 * bn_fontWidth, NULL, z1s1); 
  100.     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth, z2s1, z1s1); 
  101.     z2s2   = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z1s1);
  102.  
  103.     z3s1  = ui_xCreateLabelItem ("Type: ",pannel,colom1 * bn_fontWidth,NULL,z2s1); 
  104.     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z3s1,z2s1); 
  105.     z3s2  = ui_xCreateFrameLabelItem ("",pannel,bn_intWidth,dummy,z2s1);
  106.     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z3s2,z2s1);
  107.     z3s3  = ui_xCreateFrameLabelItem (plane_type[PLANE_type],pannel,bn_intWidth,dummy,z2s1);
  108.  
  109.     z4s1  = ui_xCreateLabelItem ("No. of units in x-direction: ",pannel,colom1 * bn_fontWidth,NULL,z3s1); 
  110.     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth,z4s1,z3s1); 
  111.     z4s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z3s1);
  112.     dummy = ui_xCreateLabelItem (" ", pannel, 5 * bn_fontWidth,z4s2,z3s1); 
  113.     z4s3  = ui_xCreateDialogItem ("z4s3", pannel,"",bn_intWidth,dummy,z3s1);
  114.  
  115.     z5s1  = ui_xCreateLabelItem ("No. of units in y-direction: ",pannel,colom1 * bn_fontWidth,NULL,z4s1); 
  116.     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth,z5s1,z4s1); 
  117.     z5s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z4s1);
  118.     dummy = ui_xCreateLabelItem (" ", pannel, 5 * bn_fontWidth,z5s2,z4s1); 
  119.     z5s3  = ui_xCreateDialogItem ("z4s3", pannel, "",bn_intWidth,dummy,z4s1);
  120.  
  121.  
  122.     z6s1  = ui_xCreateLabelItem ("z-coordinates of the plane: ",pannel,colom1 * bn_fontWidth,NULL,z5s1); 
  123.     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z6s1,z5s1); 
  124.     z6s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z5s1);
  125.     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z6s2,z5s1); 
  126.     z6s3  = ui_xCreateDialogItem ("z4s3",pannel,"",bn_intWidth,dummy,z5s1);
  127.  
  128.     z7s1  = ui_xCreateLabelItem ("Rel. Position: ",pannel,colom1 * bn_fontWidth,NULL,z6s1); 
  129.     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z7s1,z6s1); 
  130.     z7s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z6s1);
  131.     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z7s2,z6s1);
  132.     z7s3  = ui_xCreateFrameLabelItem (plane_pos[PLANE_pos],pannel,bn_intWidth,dummy,z6s1);
  133.  
  134.     dummy         = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,z7s1); 
  135.     
  136.     plane_edit = ui_xCreateLabelItem ("Edit Plane: ",pannel,15 * bn_fontWidth,NULL,dummy); 
  137.     plane_enter      = bn_basics_xCreateButtonItem ("enter",pannel,plane_edit,dummy);
  138.       XtAddCallback(plane_enter,XtNcallback,(XtCallbackProc)enter_plane_PROC,NULL);
  139.     plane_insert     = bn_basics_xCreateButtonItem ("insert",pannel,plane_enter,dummy);
  140.       XtAddCallback(plane_insert,XtNcallback,(XtCallbackProc)insert_plane_PROC,NULL);
  141.     plane_overwrite  = bn_basics_xCreateButtonItem ("overwrite",pannel,plane_insert,dummy);
  142.       XtAddCallback(plane_overwrite,XtNcallback,(XtCallbackProc)overwrite_plane_PROC,NULL);
  143.     plane_delete     = bn_basics_xCreateButtonItem ("delete",pannel,plane_overwrite,dummy);
  144.       XtAddCallback(plane_delete,XtNcallback,(XtCallbackProc)delete_plane_PROC,NULL);
  145.  
  146.     dummy         = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,plane_edit); 
  147.     plane_to_edit = bn_basics_xCreateButtonItem ("plane_to_edit",pannel,dummy,plane_edit);
  148.       XtAddCallback(plane_to_edit,XtNcallback,(XtCallbackProc)current_plane_to_editor_PROC,NULL);
  149.     type          = bn_basics_xCreateButtonItem ("type",pannel,plane_to_edit,plane_edit);
  150.       XtAddCallback(type,XtNcallback,(XtCallbackProc)type_PROC,NULL);
  151.     pos           = bn_basics_xCreateButtonItem ("pos",pannel,type,plane_edit);
  152.       XtAddCallback(pos,XtNcallback,(XtCallbackProc)pos_PROC,NULL);
  153.  
  154.     current_plane = ui_xCreateLabelItem ("Current plane: ",pannel,15 * bn_fontWidth,NULL,dummy); 
  155.     plane_first         = bn_basics_xCreateButtonItem ("first",pannel,current_plane,dummy);
  156.       XtAddCallback(plane_first,XtNcallback,(XtCallbackProc)beginning_plane_PROC,NULL);
  157.     plane_prev          = bn_basics_xCreateButtonItem ("prev",pannel,plane_first,dummy);
  158.       XtAddCallback(plane_prev,XtNcallback,(XtCallbackProc)backward_plane_PROC,NULL);
  159.     plane_next          = bn_basics_xCreateButtonItem ("next",pannel,plane_prev,dummy);
  160.       XtAddCallback(plane_next,XtNcallback,(XtCallbackProc)forward_plane_PROC,NULL);
  161.     plane_last          = bn_basics_xCreateButtonItem ("last",pannel,plane_next,dummy);
  162.       XtAddCallback(plane_last,XtNcallback,(XtCallbackProc)end_plane_PROC,NULL);
  163. }
  164.  
  165.  
  166.  
  167. /*****************************************************************************
  168.   FUNCTION : bn_createLinkPanel
  169.  
  170.   PURPOSE  : creates the link panel, which is part of the bignet-window
  171.   NOTES    :
  172.   RETURNS  :
  173.  
  174.   UPDATE   : 20.12.1991
  175. ******************************************************************************/
  176.  
  177. static void bn_createLinkPannel (Widget parent)
  178.  
  179. {
  180.     Widget pannel;
  181.     Widget dummy,dummy1,dummy2;
  182.     Widget link_edit,current_link;
  183.     Widget link_enter,link_delete,link_overwrite,link_to_edit,full_connection,shortcut_connection;
  184.     Widget link_first,link_last,link_prev,link_next;
  185.     Arg          arg[25];
  186.     Cardinal     n;
  187.   
  188.     n = 0;  
  189.  
  190.     pannel = XtCreateManagedWidget ("pannel", formWidgetClass, parent, arg, n);
  191.  
  192.  
  193.  
  194.     dummy1 = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,NULL); 
  195.     z8s2   = ui_xCreateLabelItem (" Current Link ", pannel,14*bn_fontWidth,dummy1,NULL); 
  196.     z8s3   = ui_xCreateLabelItem ("       Edit Link", pannel,16*bn_fontWidth,z8s2,NULL); 
  197.  
  198.     dummy2 = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,dummy1); 
  199.     z9s1   = ui_xCreateLabelItem ("Source", pannel,8*bn_fontWidth,dummy2,dummy1); 
  200.     z9s2   = ui_xCreateLabelItem ("Target", pannel,8*bn_fontWidth,z9s1,dummy1); 
  201.     z9s3   = ui_xCreateLabelItem ("  Source", pannel,8*bn_fontWidth,z9s2,dummy1); 
  202.     z9s4   = ui_xCreateLabelItem (" Target", pannel,8*bn_fontWidth,z9s3,dummy1); 
  203.  
  204.     z10s1  = ui_xCreateLabelItem ("Plane", pannel,15*bn_fontWidth,NULL,dummy2); 
  205.     z10s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z10s1,dummy2);
  206.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z10s2,dummy2); 
  207.     z10s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,dummy2);
  208.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z10s3,dummy2); 
  209.     z10s4  = ui_xCreateDialogItem ("z10s4", pannel,"",bn_intWidth,dummy,dummy2);
  210.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z10s4,dummy2); 
  211.     z10s5  = ui_xCreateDialogItem ("z10s5", pannel, "",bn_intWidth,dummy,dummy2);
  212.  
  213.     z11s1  = ui_xCreateLabelItem ("Cluster", pannel,15*bn_fontWidth,NULL,z10s1); 
  214.  
  215.     z12s1  = ui_xCreateLabelItem ("  Coordinates", pannel,15*bn_fontWidth,NULL,z11s1); 
  216.  
  217.     z13s1  = ui_xCreateLabelItem ("        x:", pannel,15*bn_fontWidth,NULL,z12s1); 
  218.     z13s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z13s1,z12s1);
  219.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z13s2,z12s1); 
  220.     z13s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z12s1);
  221.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z13s3,z12s1); 
  222.     z13s4  = ui_xCreateDialogItem ("z13s4", pannel, "",bn_intWidth,dummy,z12s1);
  223.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z13s4,z12s1); 
  224.     z13s5  = ui_xCreateDialogItem ("z13s5", pannel, "",bn_intWidth,dummy,z12s1);
  225.  
  226.     z14s1  = ui_xCreateLabelItem ("        y:", pannel,15*bn_fontWidth,NULL,z13s1); 
  227.     z14s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z14s1,z13s1);
  228.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z14s2,z13s1); 
  229.     z14s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z13s1);
  230.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z14s3,z13s1); 
  231.     z14s4  = ui_xCreateDialogItem ("z14s4", pannel, "",bn_intWidth,dummy,z13s1);
  232.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z14s4,z13s1); 
  233.     z14s5  = ui_xCreateDialogItem ("z14s5", pannel, "",bn_intWidth,dummy,z13s1);
  234.  
  235.     z15s1  = ui_xCreateLabelItem ("   width :", pannel,15*bn_fontWidth,NULL,z14s1); 
  236.     z15s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z15s1,z14s1);
  237.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z15s2,z14s1); 
  238.     z15s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z14s1);
  239.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z15s3,z14s1); 
  240.     z15s4  = ui_xCreateDialogItem ("z15s4", pannel, "",bn_intWidth,dummy,z14s1);
  241.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z15s4,z14s1); 
  242.     z15s5  = ui_xCreateDialogItem ("z15s5", pannel, "",bn_intWidth,dummy,z14s1);
  243.  
  244.     z16s1  = ui_xCreateLabelItem ("   height:", pannel,15*bn_fontWidth,NULL,z15s1); 
  245.     z16s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z16s1,z15s1);
  246.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z16s2,z15s1); 
  247.     z16s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z15s1);
  248.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z16s3,z15s1); 
  249.     z16s4  = ui_xCreateDialogItem ("z16s4", pannel, "",bn_intWidth,dummy,z15s1);
  250.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z16s4,z15s1); 
  251.     z16s5  = ui_xCreateDialogItem ("z16s5", pannel, "",bn_intWidth,dummy,z15s1);
  252.  
  253.     z17s1  = ui_xCreateLabelItem ("Unit", pannel,15*bn_fontWidth,NULL,z16s1); 
  254.  
  255.     z18s1  = ui_xCreateLabelItem ("  Coordinates", pannel,15*bn_fontWidth,NULL,z17s1); 
  256.  
  257.     z19s1  = ui_xCreateLabelItem ("        x:", pannel,15*bn_fontWidth,NULL,z18s1); 
  258.     z19s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z19s1,z18s1);
  259.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z19s2,z18s1); 
  260.     z19s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z18s1);
  261.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z19s3,z18s1); 
  262.     z19s4  = ui_xCreateDialogItem ("z19s4", pannel, "",bn_intWidth,dummy,z18s1);
  263.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z19s4,z18s1); 
  264.     z19s5  = ui_xCreateDialogItem ("z19s5", pannel, "",bn_intWidth,dummy,z18s1);
  265.  
  266.     z20s1  = ui_xCreateLabelItem ("        y:", pannel,15*bn_fontWidth,NULL,z19s1); 
  267.     z20s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z20s1,z19s1);
  268.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z20s2,z19s1); 
  269.     z20s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z19s1);
  270.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z20s3,z19s1); 
  271.     z20s4  = ui_xCreateDialogItem ("z20s4", pannel, "",bn_intWidth,dummy,z19s1);
  272.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z20s4,z19s1); 
  273.     z20s5  = ui_xCreateDialogItem ("z20s5", pannel, "",bn_intWidth,dummy,z19s1);
  274.  
  275.     z21s1  = ui_xCreateLabelItem ("Move", pannel,15*bn_fontWidth,NULL,z20s1); 
  276.  
  277.  
  278.     z22s1  = ui_xCreateLabelItem ("       dx:", pannel,15*bn_fontWidth,NULL,z21s1); 
  279.     z22s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z22s1,z21s1);
  280.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z22s2,z21s1); 
  281.     z22s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z21s1);
  282.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z22s3,z21s1); 
  283.     z22s4  = ui_xCreateDialogItem ("z22s4", pannel, "",bn_intWidth,dummy,z21s1);
  284.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z22s4,z21s1); 
  285.     z22s5  = ui_xCreateDialogItem ("z22s5", pannel, "",bn_intWidth,dummy,z21s1);
  286.  
  287.     z23s1  = ui_xCreateLabelItem ("       dy:", pannel,15*bn_fontWidth,NULL,z22s1); 
  288.     z23s2  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,z23s1,z22s1);
  289.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z23s2,z22s1); 
  290.     z23s3  = ui_xCreateFrameLabelItem ("", pannel,bn_intWidth,dummy,z22s1);
  291.     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z23s3,z22s1); 
  292.     z23s4  = ui_xCreateDialogItem ("z23s4", pannel, "",bn_intWidth,dummy,z22s1);
  293.     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z23s4,z22s1); 
  294.     z23s5  = ui_xCreateDialogItem ("z23s5", pannel, "",bn_intWidth,dummy,z22s1);
  295.  
  296.  
  297.     dummy           = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,z23s1); 
  298.  
  299.     link_edit       = ui_xCreateLabelItem ("Edit Link: ",pannel,15 * bn_fontWidth,NULL,dummy); 
  300.     link_enter      = bn_basics_xCreateButtonItem ("enter",pannel,link_edit,dummy);
  301.       XtAddCallback(link_enter,XtNcallback,(XtCallbackProc)enter_link_PROC,NULL);
  302.     link_overwrite  = bn_basics_xCreateButtonItem ("overwrite",pannel,link_enter,dummy);
  303.       XtAddCallback(link_overwrite,XtNcallback,(XtCallbackProc)overwrite_link_PROC,NULL);
  304.     link_to_edit    = bn_basics_xCreateButtonItem ("link_to_edit",pannel,link_overwrite,dummy);
  305.       XtAddCallback(link_to_edit,XtNcallback,(XtCallbackProc)current_link_to_editor_PROC,NULL);
  306.     link_delete     = bn_basics_xCreateButtonItem ("delete",pannel,link_to_edit,dummy);
  307.       XtAddCallback(link_delete,XtNcallback,(XtCallbackProc)delete_link_PROC,NULL);
  308.  
  309.     dummy           = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,link_edit); 
  310.  
  311.     full_connection = bn_basics_xCreateButtonItem ("full_connection",pannel,dummy,link_edit);
  312.       XtAddCallback(full_connection,XtNcallback,(XtCallbackProc)full_connection_PROC,NULL);
  313.     shortcut_connection = bn_basics_xCreateButtonItem ("shortcut_connection",pannel,full_connection,link_edit);
  314.       XtAddCallback(shortcut_connection,XtNcallback,(XtCallbackProc)shortcut_connection_PROC,NULL);
  315.  
  316.     current_link  = ui_xCreateLabelItem ("Current Link: ",pannel,15 * bn_fontWidth,NULL,dummy); 
  317.     link_first    = bn_basics_xCreateButtonItem ("first",pannel,current_link,dummy);
  318.       XtAddCallback(link_first,XtNcallback,(XtCallbackProc)beginning_link_PROC,NULL);
  319.     link_prev     = bn_basics_xCreateButtonItem ("prev",pannel,link_first,dummy);
  320.       XtAddCallback(link_prev,XtNcallback,(XtCallbackProc)backward_link_PROC,NULL);
  321.     link_next     = bn_basics_xCreateButtonItem ("next",pannel,link_prev,dummy);
  322.       XtAddCallback(link_next,XtNcallback,(XtCallbackProc)forward_link_PROC,NULL);
  323.     link_last     = bn_basics_xCreateButtonItem ("last",pannel,link_next,dummy);
  324.       XtAddCallback(link_last,XtNcallback,(XtCallbackProc)end_link_PROC,NULL);
  325.  
  326.   }
  327.  
  328.  
  329. /*****************************************************************************
  330.   FUNCTION : exit_PROC
  331.  
  332.   PURPOSE  : callback function of the exit-buttom. You are leaving bignet.
  333.   NOTES    :
  334.   RETURNS  :
  335.  
  336.   UPDATE   : 20.12.1991
  337. ******************************************************************************/
  338.  
  339. static void exit_PROC (void)
  340.  
  341. {
  342.     XtDestroyWidget (baseWidget);
  343.     bignet_widget_open = 0;
  344. }
  345.  
  346. /*****************************************************************************
  347.   FUNCTION : bn_createBignet
  348.  
  349.   PURPOSE  : creates the bignet-window.
  350.   NOTES    :
  351.   RETURNS  :
  352.  
  353.   UPDATE   : 20.12.1991
  354. ******************************************************************************/
  355.  
  356. void bn_createBignet (void)
  357.  
  358. {
  359.     Widget       box;
  360.     Widget       create_net,exit,cancel;
  361.     Arg          arg[25];
  362.     Cardinal     n;
  363.     char         buf[40];
  364.  
  365.     if(! bignet_widget_open)
  366.       {
  367.        sprintf (buf, "BigNet (Feed Forward)");
  368.        n = 0;  
  369. /*
  370.        XtSetArg(arg[n],XtNminHeight,699); n++;
  371.        XtSetArg(arg[n],XtNminWidth,410); n++;  
  372.        XtSetArg(arg[n],XtNmaxHeight,699); n++;
  373.        XtSetArg(arg[n],XtNmaxWidth,410); n++;
  374. */       
  375.  
  376.        baseWidget = XtCreatePopupShell (buf, topLevelShellWidgetClass, ui_toplevel, arg, n); 
  377.        n = 0;  
  378.        box = XtCreateManagedWidget ("box", boxWidgetClass, baseWidget, arg, n);
  379.        bn_createPlanePannel (box); 
  380.        bn_createLinkPannel(box);
  381.  
  382.        create_net = bn_basics_xCreateButtonItem ("create_net",box,NULL,NULL);
  383.          XtAddCallback(create_net,XtNcallback,(XtCallbackProc)create_net_PROC,NULL);
  384.        exit = bn_basics_xCreateButtonItem ("done",box,create_net,NULL);
  385.        XtAddCallback(exit,XtNcallback,(XtCallbackProc)exit_PROC,NULL);
  386.        cancel     = bn_basics_xCreateButtonItem ("cancel",box,exit,NULL);
  387.        XtAddCallback(cancel,XtNcallback,(XtCallbackProc)cancel_net_PROC,NULL);
  388.  
  389.        ui_checkWindowPosition(baseWidget);
  390.        XtPopup (baseWidget, XtGrabNone);
  391.        ui_xDontResizeWidget(baseWidget);
  392.        bignet_widget_open = 1;
  393.        if(PLANE_length != 0){
  394.          write_current_plane();
  395.          if(LINK_length != 0) {
  396.            write_current_link();
  397.          }
  398.        }
  399.  
  400.      } else {
  401.     
  402.         ui_confirmOk ("BigNet (Feed Forward) already loaded");
  403.  
  404.      }
  405. }
  406.  
  407.  
  408.    
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418. /*************************************************************************
  419.  
  420.      File bn_cretae_net 
  421.  
  422. ***************************************************************************/
  423.  
  424.  
  425. /*****************************************************************************
  426.   FUNCTION : create_net_PROC
  427.  
  428.   PURPOSE  : creates a SNNS-net in two steps:
  429.              1. calls up a function, which creates SNNS-units
  430.              2. calls up a function, which connections the SNNS-units.
  431.   NOTES    : There are nine different ways (PLANE_TO_PLANE, PLANE_TO_CLUSTER ...) 
  432.              two different planes can be connected.
  433.   RETURNS  :
  434.  
  435.   UPDATE   : 20.12.1991
  436. ******************************************************************************/
  437.  
  438. static void create_net_PROC(void)
  439.  
  440. {
  441.  LINK  *LINK_element=LINK_first_element;
  442.  PLANE *source_plane,*target_plane;
  443.  int move,type_of_connection=1;
  444.  int create=1;
  445.  
  446.  BN_ERROR = 0;
  447.  
  448.  if(krui_getNoOfUnits() != 0) {
  449.    if(! ui_confirmYes("Create will erase current network. Create?")) {
  450.      create = 0;
  451.    }
  452.  }
  453.  
  454.  if(create && (PLANE_length != 0)) {
  455.  
  456.    krui_deleteNet();
  457.  
  458.    calculate_first_snns_unit_no_of_plane();
  459.    create_snns_unit(); 
  460.  
  461.    while((LINK_element != NULL) && (! BN_ERROR)) {
  462.  
  463.      move               = (*LINK_element).move;
  464.      type_of_connection = (*LINK_element).type_of_connection;
  465.      source_plane       =  get_plane((*LINK_element).SOURCE.plane);
  466.      target_plane       =  get_plane((*LINK_element).TARGET.plane);
  467.    
  468.      switch(type_of_connection) {
  469.        case PLANE_TO_PLANE: {
  470.                              make_link(source_plane,0,0,
  471.                                        (*source_plane).width,(*source_plane).height,
  472.                                        target_plane,0,0,
  473.                                        (*target_plane).width,(*target_plane).height);
  474.                              break;
  475.                             }
  476.        case PLANE_TO_CLUSTER: {
  477.                              make_link(source_plane,0,0,
  478.                                        (*source_plane).width,(*source_plane).height,
  479.                                        target_plane,(*LINK_element).TARGET.CLUSTER.x-1,(*LINK_element).TARGET.CLUSTER.y-1,
  480.                                        (*LINK_element).TARGET.CLUSTER.width,(*LINK_element).TARGET.CLUSTER.height);
  481.                              break;
  482.                             }
  483.        case PLANE_TO_UNIT: {
  484.                              make_link(source_plane,0,0,
  485.                                        (*source_plane).width,(*source_plane).height,
  486.                                        target_plane,(*LINK_element).TARGET.UNIT.x-1,(*LINK_element).TARGET.UNIT.y-1,
  487.                                        1,1);
  488.                              break;
  489.                             }  
  490.        case CLUSTER_TO_PLANE: {
  491.                                make_link(source_plane,(*LINK_element).SOURCE.CLUSTER.x-1,(*LINK_element).SOURCE.CLUSTER.y-1,
  492.                                          (*LINK_element).SOURCE.CLUSTER.width,(*LINK_element).SOURCE.CLUSTER.height,
  493.                                          target_plane,0,0,
  494.                                          (*target_plane).width,(*target_plane).height);
  495.  
  496.                                 break;
  497.                                }
  498.        case CLUSTER_TO_CLUSTER: {
  499.                               if(move) {
  500.                                 make_move_link(source_plane,(*LINK_element).SOURCE.CLUSTER.x-1,(*LINK_element).SOURCE.CLUSTER.y-1,
  501.                                                (*LINK_element).SOURCE.CLUSTER.width,(*LINK_element).SOURCE.CLUSTER.height,
  502.                                                target_plane,(*LINK_element).TARGET.CLUSTER.x-1,(*LINK_element).TARGET.CLUSTER.y-1,
  503.                                                (*LINK_element).TARGET.CLUSTER.width,(*LINK_element).TARGET.CLUSTER.height,
  504.                                                (*LINK_element).SOURCE.MOVE.delta_x,(*LINK_element).SOURCE.MOVE.delta_y,
  505.                                                (*LINK_element).TARGET.MOVE.delta_x,(*LINK_element).TARGET.MOVE.delta_y);
  506.                                  }
  507.                                  else {
  508.                                    make_link(source_plane,(*LINK_element).SOURCE.CLUSTER.x-1,(*LINK_element).SOURCE.CLUSTER.y-1,
  509.                                              (*LINK_element).SOURCE.CLUSTER.width,(*LINK_element).SOURCE.CLUSTER.height,
  510.                                              target_plane,(*LINK_element).TARGET.CLUSTER.x-1,(*LINK_element).TARGET.CLUSTER.y-1,
  511.                                              (*LINK_element).TARGET.CLUSTER.width,(*LINK_element).TARGET.CLUSTER.height);
  512.                                  }
  513.                                  break;
  514.                                 }
  515.        case CLUSTER_TO_UNIT: {
  516.                               if(move) {
  517.                                 make_move_link(source_plane,(*LINK_element).SOURCE.CLUSTER.x-1,(*LINK_element).SOURCE.CLUSTER.y-1,
  518.                                                (*LINK_element).SOURCE.CLUSTER.width,(*LINK_element).SOURCE.CLUSTER.height,
  519.                                                target_plane,(*LINK_element).TARGET.UNIT.x-1,(*LINK_element).TARGET.UNIT.y-1,
  520.                                                1,1,
  521.                                                (*LINK_element).SOURCE.MOVE.delta_x,(*LINK_element).SOURCE.MOVE.delta_y,
  522.                                                (*LINK_element).TARGET.MOVE.delta_x,(*LINK_element).TARGET.MOVE.delta_y);
  523.                                  }
  524.                                  else {
  525.                                    make_link(source_plane,(*LINK_element).SOURCE.CLUSTER.x-1,(*LINK_element).SOURCE.CLUSTER.y-1,
  526.                                              (*LINK_element).SOURCE.CLUSTER.width,(*LINK_element).SOURCE.CLUSTER.height,
  527.                                              target_plane,(*LINK_element).TARGET.UNIT.x-1,(*LINK_element).TARGET.UNIT.y-1,
  528.                                              1,1);
  529.                                  }
  530.                                  break;
  531.                                 }
  532.        case UNIT_TO_PLANE: {
  533.                             make_link(source_plane,(*LINK_element).SOURCE.UNIT.x-1,(*LINK_element).SOURCE.UNIT.y-1,
  534.                                       1,1,
  535.                                       target_plane,0,0,
  536.                                       (*target_plane).width,(*target_plane).height);
  537.                             break;
  538.                     }
  539.        case UNIT_TO_CLUSTER: {
  540.                               if(move) {
  541.                                 make_move_link(source_plane,(*LINK_element).SOURCE.UNIT.x-1,(*LINK_element).SOURCE.UNIT.y-1,
  542.                                                1,1,
  543.                                                target_plane,(*LINK_element).TARGET.CLUSTER.x-1,(*LINK_element).TARGET.CLUSTER.y-1,
  544.                                                (*LINK_element).TARGET.CLUSTER.width,(*LINK_element).TARGET.CLUSTER.height,
  545.                                                (*LINK_element).SOURCE.MOVE.delta_x,(*LINK_element).SOURCE.MOVE.delta_y,
  546.                                                (*LINK_element).TARGET.MOVE.delta_x,(*LINK_element).TARGET.MOVE.delta_y);
  547.                     }
  548.                               else {
  549.                                 make_link(source_plane,(*LINK_element).SOURCE.UNIT.x-1,(*LINK_element).SOURCE.UNIT.y-1,
  550.                                           1,1,
  551.                                           target_plane,(*LINK_element).TARGET.CLUSTER.x-1,(*LINK_element).TARGET.CLUSTER.y-1,
  552.                                           (*LINK_element).TARGET.CLUSTER.width,(*LINK_element).TARGET.CLUSTER.height);
  553.                             }
  554.                               break;
  555.                          }
  556.        case UNIT_TO_UNIT: {
  557.                            if(move) {
  558.                              make_move_link(source_plane,(*LINK_element).SOURCE.UNIT.x-1,(*LINK_element).SOURCE.UNIT.y-1,
  559.                                             1,1,
  560.                                             target_plane,(*LINK_element).TARGET.UNIT.x-1,(*LINK_element).TARGET.UNIT.y-1,
  561.                                             1,1,
  562.                                             (*LINK_element).SOURCE.MOVE.delta_x,(*LINK_element).SOURCE.MOVE.delta_y,
  563.                                             (*LINK_element).TARGET.MOVE.delta_x,(*LINK_element).TARGET.MOVE.delta_y);
  564.                }
  565.                            else {
  566.                               make_link(source_plane,(*LINK_element).SOURCE.UNIT.x-1,(*LINK_element).SOURCE.UNIT.y-1,
  567.                                         1,1,
  568.                                         target_plane,(*LINK_element).TARGET.UNIT.x-1,(*LINK_element).TARGET.UNIT.y-1,
  569.                                         1,1);
  570.                            }
  571.                            break;
  572.                       }
  573.        } /* switch */
  574.      LINK_element = (*LINK_element).next;
  575.    } /* while */    
  576.    bn_display_net();
  577.  }/* if */ 
  578. }
  579.  
  580. /*****************************************************************************
  581.   FUNCTION : calculate_first_snns_unit_no_of_plane
  582.  
  583.   PURPOSE  : calculates the SNNS unit no of the left upper corner of every
  584.              plane.
  585.  
  586.   NOTES    : relative to this unit no, knowing the width and the height of the
  587.              planes, all other SNNS unit numbers of every plane can be 
  588.              calculated. That's important for the function create_snns_unit.
  589.   RETURNS  :
  590.  
  591.   UPDATE   : 20.12.1991
  592. ******************************************************************************/
  593.  
  594. static void calculate_first_snns_unit_no_of_plane(void)
  595.  
  596. {
  597.  PLANE *PLANE_element = PLANE_first_element;
  598.  
  599.  (*PLANE_element).begin = 1;  
  600.  PLANE_element = (*PLANE_element).next;
  601.  
  602.  while(PLANE_element != NULL) {
  603.    (*PLANE_element).begin = (*(*PLANE_element).before).width *
  604.                                 (*(*PLANE_element).before).height +
  605.                   (*(*PLANE_element).before).begin;
  606.    PLANE_element = (*PLANE_element).next; 
  607.  }
  608. }
  609.  
  610.  
  611.  
  612. /*****************************************************************************
  613.   FUNCTION : calculate_x_begin
  614.  
  615.   PURPOSE  : calculates the x-coordinate of a plane, where the plane is
  616.              positioned in the display window.
  617.              plane.
  618.   NOTES    : 
  619.   RETURNS  : The X-Position
  620.  
  621.   UPDATE   : 20.12.1991
  622. ******************************************************************************/
  623.  
  624.  
  625. static int calculate_x_begin(int *new_x_begin,int *old_x_begin,int *x_max,int width,int pos)
  626.  
  627. {
  628.  if(pos == BN_RIGHT) {
  629.    
  630.    *new_x_begin = *x_max + 2; 
  631.    *x_max = *new_x_begin + width;
  632.    *old_x_begin = *new_x_begin;
  633.    return *new_x_begin;
  634.  }
  635.  else if(pos == BN_BELOW) {
  636.    if(*x_max < (*old_x_begin + width)) {
  637.      *x_max = *old_x_begin + width;
  638.    }
  639.    return *old_x_begin; 
  640.  }
  641.  else if(pos == BN_LEFT) {
  642.    *x_max = 0;
  643.    *old_x_begin = 2;
  644.  
  645.    *new_x_begin = *x_max + 2;
  646.    *x_max = *new_x_begin + width;
  647.    return *new_x_begin;
  648.  }
  649.  return 0;
  650. }
  651.  
  652.  
  653. /*****************************************************************************
  654.   FUNCTION : calculate_y_begin
  655.  
  656.   PURPOSE  : calculates the y-coordinate of a plane, where the plane is
  657.              positioned in the display window.
  658.              plane.
  659.  
  660.   NOTES    : 
  661.   RETURNS  : The Y-Position
  662.  
  663.   UPDATE   : 20.12.1991
  664. ******************************************************************************/
  665.  
  666. static int calculate_y_begin(int *absolute_y_max,int *relative_y_max,int *y_offset,int height,int pos)
  667.  
  668. {
  669. int y_begin;
  670.  
  671.  if(pos == BN_RIGHT) {
  672.    y_begin = *y_offset + 2;         
  673.    *relative_y_max = y_begin + height;
  674.    if(*absolute_y_max < *relative_y_max) {
  675.      *absolute_y_max = *relative_y_max;
  676.    }
  677.  }
  678.  else if(pos == BN_BELOW) {
  679.    y_begin = *relative_y_max + 2;   
  680.    *relative_y_max = y_begin + height;
  681.    if(*absolute_y_max < *relative_y_max) {
  682.      *absolute_y_max = *relative_y_max;
  683.    }
  684.  }
  685.  else if(pos == BN_LEFT) {
  686.    *y_offset = *absolute_y_max;
  687.    y_begin = *y_offset + 2;
  688.    *absolute_y_max = y_begin + height;
  689.    *relative_y_max = y_begin + height;
  690.  }
  691.  return y_begin;
  692. }
  693.  
  694.  
  695. /*****************************************************************************
  696.   FUNCTION : create_snns_unit
  697.  
  698.   PURPOSE  : creates for every unit of a plane a SNNS default unit.
  699.  
  700.   NOTES    : 
  701.   RETURNS  :
  702.  
  703.   UPDATE   : 20.12.1991
  704. ******************************************************************************/
  705.  
  706. static void create_snns_unit(void)
  707.  
  708. {
  709.  struct PosType unit_pos;
  710.  
  711.  PLANE *PLANE_element = PLANE_first_element; 
  712.  int x,y,width,height,unit_no,pos,ret;
  713.  int y_offset=0,relative_y_max=0,absolute_y_max=0,y_begin;
  714.  int x_max=0,old_x_begin=2,new_x_begin,x_begin;
  715.  
  716.  ret = krui_allocateUnits((*PLANE_last_element).width * 
  717.                              (*PLANE_last_element).height +
  718.                                (*PLANE_last_element).begin-1);
  719.  if(ret != 0){
  720.    ui_tw_errorMessage(krui_error(ret));
  721.    BN_ERROR = 1;
  722.  }
  723.  
  724.  while((! BN_ERROR) && (PLANE_element != NULL)) {
  725.  
  726.    height = (*PLANE_element).height;
  727.    width  = (*PLANE_element).width;
  728.    pos    = (*PLANE_element).pos;
  729.     
  730.    y_begin = calculate_y_begin(&absolute_y_max,&relative_y_max,&y_offset,height,pos);
  731.    x_begin = calculate_x_begin(&new_x_begin,&old_x_begin,&x_max,width,pos);
  732.  
  733.    for(y=0;y<height;y++){
  734.      for(x=0;x<width;x++){
  735.        unit_no = krui_createDefaultUnit();
  736.        if(unit_no<0) ui_checkError(unit_no);
  737.        ret = krui_setUnitTType(unit_no,(*PLANE_element).type+1);
  738.        if(ret != 0){
  739.          ui_tw_errorMessage(krui_error(ret));
  740.          BN_ERROR = 1;
  741.        }
  742.       
  743.        unit_pos.x = x_begin + x;
  744.        unit_pos.y = y_begin + y;
  745.  
  746.        krui_setUnitPosition(unit_no,&unit_pos);
  747.      }/*for*/
  748.    }/*for*/
  749.  
  750.    PLANE_element = (*PLANE_element).next;
  751.  }/*while*/
  752. }
  753.  
  754.  
  755. /*****************************************************************************
  756.   FUNCTION : make_link
  757.  
  758.   PURPOSE  : creates the links between two planes.
  759.  
  760.   NOTES    : 
  761.   RETURNS  :
  762.  
  763.   UPDATE   : 20.12.1991
  764. ******************************************************************************/
  765.  
  766. static void make_link(PLANE *LINK_source_plane,int LINK_source_cluster_x,int LINK_source_cluster_y,
  767.                      int LINK_source_cluster_width,int LINK_source_cluster_height,
  768.                      PLANE *LINK_target_plane,int LINK_target_cluster_x,int LINK_target_cluster_y,
  769.                      int LINK_target_cluster_width,int LINK_target_cluster_height)
  770.  
  771. {
  772.  int i,j,k,l,ret,target_unit,source_unit;
  773.  
  774.   for(i = LINK_target_cluster_y;i < LINK_target_cluster_height+LINK_target_cluster_y;i++)
  775.    for(j = LINK_target_cluster_x;j < LINK_target_cluster_width+LINK_target_cluster_x;j++)
  776.       {
  777.        target_unit = (*LINK_target_plane).begin + 
  778.                        (*LINK_target_plane).width * i + j;
  779.        ret = krui_setCurrentUnit(target_unit);
  780.        if(ret != 0){
  781.          ui_tw_errorMessage(krui_error(ret));
  782.          BN_ERROR = 1;
  783.          krui_deleteNet();
  784.          goto disaster;
  785.        }
  786.        for(k = LINK_source_cluster_y;k < LINK_source_cluster_height+LINK_source_cluster_y;k++)
  787.          for(l = LINK_source_cluster_x;l < LINK_source_cluster_width+LINK_source_cluster_x;l++)
  788.            {
  789.             source_unit = (*LINK_source_plane).begin + 
  790.                              (*LINK_source_plane).width * k + l;
  791.             if((ret = krui_createLink(source_unit,0.0)) != 0){
  792.               ui_tw_errorMessage(krui_error(ret));
  793.               BN_ERROR = 1;
  794.               krui_deleteNet();
  795.               goto disaster;
  796.             }
  797.             /*printf("Source: %d --> Target: %d\n",source_unit,target_unit);*/
  798.            } 
  799.       }             
  800.  disaster: ;
  801. }
  802.  
  803.  
  804. /*****************************************************************************
  805.   FUNCTION : make_move_link
  806.  
  807.   PURPOSE  : while "moving" (see docu)  is possible the function make_link
  808.              is called up.
  809.   NOTES    : 
  810.   RETURNS  :
  811.  
  812.   UPDATE   : 20.12.1991
  813. ******************************************************************************/
  814.  
  815. static void make_move_link(PLANE *LINK_source_plane,int LINK_source_cluster_x,int LINK_source_cluster_y,
  816.                            int LINK_source_cluster_width,int LINK_source_cluster_height,
  817.                            PLANE * LINK_target_plane,int LINK_target_cluster_x,int LINK_target_cluster_y,
  818.                            int LINK_target_cluster_width,int LINK_target_cluster_height,
  819.                            int LINK_source_move_delta_x,int LINK_source_move_delta_y,
  820.                            int LINK_target_move_delta_x,int LINK_target_move_delta_y)
  821.  
  822. {
  823.  int xs_pivot=LINK_source_cluster_x;
  824.  int xt_pivot=LINK_target_cluster_x;
  825.  
  826.  do {
  827.    make_link(LINK_source_plane,LINK_source_cluster_x,LINK_source_cluster_y,
  828.              LINK_source_cluster_width,LINK_source_cluster_height,
  829.              LINK_target_plane,LINK_target_cluster_x,LINK_target_cluster_y,
  830.              LINK_target_cluster_width,LINK_target_cluster_height);
  831.  }
  832.  while(! BN_ERROR &&
  833.        move_p(LINK_source_plane,&LINK_source_cluster_y,&LINK_source_cluster_x,
  834.               LINK_source_cluster_width,LINK_source_cluster_height,
  835.               xs_pivot,LINK_source_move_delta_x,LINK_source_move_delta_y)           &&
  836.        move_p(LINK_target_plane,&LINK_target_cluster_y,&LINK_target_cluster_x,
  837.               LINK_target_cluster_width,LINK_target_cluster_height,
  838.               xt_pivot,LINK_target_move_delta_x,LINK_target_move_delta_y));
  839. }
  840.     
  841. /*****************************************************************************
  842.   FUNCTION : move_p
  843.  
  844.   PURPOSE  : tests whether the boundaries of a plane are crossed while
  845.              "moving" (see docu)
  846.  
  847.   NOTES    : 
  848.   RETURNS  : 
  849.  
  850.   UPDATE   : 20.12.1991
  851. ******************************************************************************/
  852.  
  853. static int move_p(PLANE *plane_no,int *y,int *x,int width,int height,int x_pivot,int x_step,int y_step)
  854.  
  855. {
  856.  if(x_step > 0 && ((*x)+width+x_step<=(*plane_no).width))
  857.    (*x)+= x_step;
  858.  else
  859.     if(y_step > 0 && ((*y)+height+y_step<=(*plane_no).height))
  860.       {
  861.        (*y) += y_step;
  862.        (*x) = x_pivot;
  863.       }
  864.     else
  865.       return 0;
  866.  
  867.  return 1;
  868. }
  869.  
  870. /*****************************************************************************
  871.   FUNCTION : bn_display_net
  872.  
  873.   PURPOSE  : displays the created net in the display window of SNNS.
  874.  
  875.   NOTES    : 
  876.   RETURNS  :
  877.  
  878.   UPDATE   : 20.12.1991
  879. ******************************************************************************/
  880.  
  881. static void bn_display_net(void)
  882.  
  883. {
  884.  ui_sel_resetList();
  885.  ui_net_completeRefresh(ui_currentDisplay,2);
  886.  ui_stat_displayStatus(ui_gridPosMouse);
  887.  strcpy(ui_filenameNET,"SNNS_NET");
  888.  strcpy(ui_filenameSLNET,"SNNS_NET");
  889.  ui_file_updateShellLabels();
  890. }
  891.  
  892.  
  893. /***************************************************************************
  894.  
  895.   bn_link
  896.  
  897.   PURPOSE  : Functions of the link editor.
  898.  
  899. ***************************************************************************/
  900.  
  901.  
  902. /*****************************************************************************
  903.   FUNCTION : read_link_elements
  904.  
  905.   PURPOSE  : reads the input datas of the link editor (Edit Link).
  906.  
  907.   NOTES    : 
  908.   RETURNS  : @@@
  909.  
  910.   UPDATE   : 20.12.1991
  911. ******************************************************************************/
  912.  
  913. static int read_link_elements(void)
  914.  
  915. {
  916.  LINK_source_plane = ui_xIntFromAsciiWidget(z10s4);
  917.  LINK_source_cluster_x = ui_xIntFromAsciiWidget(z13s4);
  918.  LINK_source_cluster_y = ui_xIntFromAsciiWidget(z14s4);
  919.  LINK_source_cluster_width = ui_xIntFromAsciiWidget(z15s4);
  920.  LINK_source_cluster_height = ui_xIntFromAsciiWidget(z16s4);
  921.  LINK_source_unit_x = ui_xIntFromAsciiWidget(z19s4);
  922.  LINK_source_unit_y = ui_xIntFromAsciiWidget(z20s4);
  923.  LINK_source_move_delta_x = ui_xIntFromAsciiWidget(z22s4);
  924.  LINK_source_move_delta_y = ui_xIntFromAsciiWidget(z23s4);
  925.  
  926.  LINK_target_plane = ui_xIntFromAsciiWidget(z10s5);
  927.  LINK_target_cluster_x = ui_xIntFromAsciiWidget(z13s5);
  928.  LINK_target_cluster_y = ui_xIntFromAsciiWidget(z14s5);
  929.  LINK_target_cluster_width = ui_xIntFromAsciiWidget(z15s5);
  930.  LINK_target_cluster_height = ui_xIntFromAsciiWidget(z16s5);
  931.  LINK_target_unit_x = ui_xIntFromAsciiWidget(z19s5);
  932.  LINK_target_unit_y = ui_xIntFromAsciiWidget(z20s5);
  933.  LINK_target_move_delta_x = ui_xIntFromAsciiWidget(z22s5);
  934.  LINK_target_move_delta_y = ui_xIntFromAsciiWidget(z23s5);
  935.  
  936.  return correct_link_input();
  937. }
  938.  
  939. /*****************************************************************************
  940.   FUNCTION : write_current_link
  941.  
  942.   PURPOSE  : writes the datas of the current_element to the control part 
  943.              (Current Link) of the link editor.
  944.  
  945.   NOTES    : 
  946.   RETURNS  :
  947.  
  948.   UPDATE   : 20.12.1991
  949. ******************************************************************************/
  950.  
  951. static void write_current_link(void)
  952.  
  953.  {
  954.   char buf[10];
  955.   
  956.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.plane);
  957.     ui_xSetLabel(z10s2,bn_widget_output(buf));
  958.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.x);
  959.     ui_xSetLabel(z13s2,bn_widget_output(buf));
  960.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.y);
  961.     ui_xSetLabel(z14s2,bn_widget_output(buf));
  962.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.width);
  963.     ui_xSetLabel(z15s2,bn_widget_output(buf));
  964.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.height);
  965.     ui_xSetLabel(z16s2,bn_widget_output(buf));
  966.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.UNIT.x);
  967.     ui_xSetLabel(z19s2,bn_widget_output(buf));
  968.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.UNIT.y);
  969.     ui_xSetLabel(z20s2,bn_widget_output(buf));
  970.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.MOVE.delta_x);
  971.     ui_xSetLabel(z22s2,bn_widget_output(buf));
  972.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.MOVE.delta_y);
  973.     ui_xSetLabel(z23s2,bn_widget_output(buf));
  974.  
  975.   sprintf(buf,"%d",(*LINK_current_element).TARGET.plane);
  976.     ui_xSetLabel(z10s3,bn_widget_output(buf));
  977.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.x);
  978.     ui_xSetLabel(z13s3,bn_widget_output(buf));
  979.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.y);
  980.     ui_xSetLabel(z14s3,bn_widget_output(buf));
  981.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.width);
  982.     ui_xSetLabel(z15s3,bn_widget_output(buf));
  983.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.height);
  984.     ui_xSetLabel(z16s3,bn_widget_output(buf));
  985.   sprintf(buf,"%d",(*LINK_current_element).TARGET.UNIT.x);
  986.     ui_xSetLabel(z19s3,bn_widget_output(buf));
  987.   sprintf(buf,"%d",(*LINK_current_element).TARGET.UNIT.y);
  988.     ui_xSetLabel(z20s3,bn_widget_output(buf));
  989.   sprintf(buf,"%d",(*LINK_current_element).TARGET.MOVE.delta_x);
  990.     ui_xSetLabel(z22s3,bn_widget_output(buf));
  991.   sprintf(buf,"%d",(*LINK_current_element).TARGET.MOVE.delta_y);
  992.     ui_xSetLabel(z23s3,bn_widget_output(buf));
  993. }
  994.  
  995.  
  996. /*****************************************************************************
  997.   FUNCTION : clear_current_link
  998.  
  999.   PURPOSE  : Deletes the datas standing in Current Link.
  1000.  
  1001.   NOTES    : 
  1002.   RETURNS  :
  1003.  
  1004.   UPDATE   : 20.12.1991
  1005. ******************************************************************************/
  1006.  
  1007. static void clear_current_link(void)
  1008.  
  1009.  {
  1010.   ui_xSetLabel(z10s2,"");
  1011.   ui_xSetLabel(z13s2,"");
  1012.   ui_xSetLabel(z14s2,"");
  1013.   ui_xSetLabel(z15s2,"");
  1014.   ui_xSetLabel(z16s2,"");
  1015.   ui_xSetLabel(z19s2,"");
  1016.   ui_xSetLabel(z20s2,"");
  1017.   ui_xSetLabel(z22s2,"");
  1018.   ui_xSetLabel(z23s2,"");
  1019.  
  1020.   ui_xSetLabel(z10s3,"");
  1021.   ui_xSetLabel(z13s3,"");
  1022.   ui_xSetLabel(z14s3,"");
  1023.   ui_xSetLabel(z15s3,"");
  1024.   ui_xSetLabel(z16s3,"");
  1025.   ui_xSetLabel(z19s3,"");
  1026.   ui_xSetLabel(z20s3,"");
  1027.   ui_xSetLabel(z22s3,"");
  1028.   ui_xSetLabel(z23s3,"");
  1029. }
  1030.  
  1031. /*****************************************************************************
  1032.   FUNCTION : write_current_link_to_editor
  1033.  
  1034.   PURPOSE  : writes the datas of Current Link to Edit Link
  1035.  
  1036.   NOTES    : 
  1037.   RETURNS  :
  1038.  
  1039.   UPDATE   : 20.12.1991
  1040. ******************************************************************************/
  1041.  
  1042. static void write_current_link_to_editor(void)
  1043.  
  1044.  {
  1045.   char buf[10];
  1046.  
  1047.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.plane);
  1048.     ui_xSetString(z10s4,bn_widget_output(buf));
  1049.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.x);
  1050.     ui_xSetString(z13s4,bn_widget_output(buf));
  1051.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.y);
  1052.     ui_xSetString(z14s4,bn_widget_output(buf));
  1053.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.width);
  1054.     ui_xSetString(z15s4,bn_widget_output(buf));
  1055.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.CLUSTER.height);
  1056.     ui_xSetString(z16s4,bn_widget_output(buf));
  1057.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.UNIT.x);
  1058.     ui_xSetString(z19s4,bn_widget_output(buf));
  1059.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.UNIT.y);
  1060.     ui_xSetString(z20s4,bn_widget_output(buf));
  1061.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.MOVE.delta_x);
  1062.     ui_xSetString(z22s4,bn_widget_output(buf));
  1063.   sprintf(buf,"%d",(*LINK_current_element).SOURCE.MOVE.delta_y);
  1064.     ui_xSetString(z23s4,bn_widget_output(buf));
  1065.  
  1066.   sprintf(buf,"%d",(*LINK_current_element).TARGET.plane);
  1067.     ui_xSetString(z10s5,bn_widget_output(buf));
  1068.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.x);
  1069.     ui_xSetString(z13s5,bn_widget_output(buf));
  1070.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.y);
  1071.     ui_xSetString(z14s5,bn_widget_output(buf));
  1072.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.width);
  1073.     ui_xSetString(z15s5,bn_widget_output(buf));
  1074.   sprintf(buf,"%d",(*LINK_current_element).TARGET.CLUSTER.height);
  1075.     ui_xSetString(z16s5,bn_widget_output(buf));
  1076.   sprintf(buf,"%d",(*LINK_current_element).TARGET.UNIT.x);
  1077.     ui_xSetString(z19s5,bn_widget_output(buf));
  1078.   sprintf(buf,"%d",(*LINK_current_element).TARGET.UNIT.y);
  1079.     ui_xSetString(z20s5,bn_widget_output(buf));
  1080.   sprintf(buf,"%d",(*LINK_current_element).TARGET.MOVE.delta_x);
  1081.     ui_xSetString(z22s5,bn_widget_output(buf));
  1082.   sprintf(buf,"%d",(*LINK_current_element).TARGET.MOVE.delta_y);
  1083.     ui_xSetString(z23s5,bn_widget_output(buf));
  1084.  
  1085. }
  1086.  
  1087.  
  1088. /*****************************************************************************
  1089.   FUNCTION : clear_edit_link
  1090.  
  1091.   PURPOSE  : Deletes the datas standing in Edit Link.
  1092.  
  1093.   NOTES    : 
  1094.   RETURNS  :
  1095.  
  1096.   UPDATE   : 20.12.1991
  1097. ******************************************************************************/
  1098.  
  1099. static void clear_edit_link(void)
  1100.  
  1101. {
  1102.  ui_xSetString(z10s4,"");
  1103.  ui_xSetString(z13s4,"");
  1104.  ui_xSetString(z14s4,"");
  1105.  ui_xSetString(z15s4,"");
  1106.  ui_xSetString(z16s4,"");
  1107.  ui_xSetString(z19s4,"");
  1108.  ui_xSetString(z20s4,"");
  1109.  ui_xSetString(z22s4,"");
  1110.  ui_xSetString(z23s4,"");
  1111.  
  1112.  ui_xSetString(z10s5,"");
  1113.  ui_xSetString(z13s5,"");
  1114.  ui_xSetString(z14s5,"");
  1115.  ui_xSetString(z15s5,"");
  1116.  ui_xSetString(z16s5,"");
  1117.  ui_xSetString(z19s5,"");
  1118.  ui_xSetString(z20s5,"");
  1119.  ui_xSetString(z22s5,"");
  1120.  ui_xSetString(z23s5,"");
  1121. }
  1122.  
  1123.  
  1124. /*****************************************************************************
  1125.   FUNCTION : enter_link_PROC
  1126.  
  1127.   PURPOSE  : callback function, which enters a link element at the end of the 
  1128.              link list.
  1129.  
  1130.   NOTES    : the link list contains all datas entered by the link editor.
  1131.              Every link element is a struct (see bn_types.c)
  1132.   RETURNS  :
  1133.  
  1134.   UPDATE   : 20.12.1991
  1135. ******************************************************************************/
  1136.  
  1137. static void enter_link_PROC(void)
  1138.  
  1139. {
  1140.  if(read_link_elements()){
  1141.    enter_link();
  1142.    write_current_link();
  1143.    clear_edit_link();
  1144.  }
  1145. }
  1146.  
  1147. /*****************************************************************************
  1148.   FUNCTION : full_connection_PROC
  1149.  
  1150.   PURPOSE  : callback function, which creates links between planes (see docu)
  1151.  
  1152.   NOTES    : 
  1153.   RETURNS  :
  1154.  
  1155.   UPDATE   : 20.12.1991
  1156. ******************************************************************************/
  1157.  
  1158. static void full_connection_PROC(void)
  1159.  
  1160. {
  1161.  while(LINK_length) {
  1162.    delete_current_link();
  1163.  }
  1164.  if(full_connection()) {
  1165.    write_current_link();
  1166.  }
  1167. }
  1168.  
  1169. /*****************************************************************************
  1170.   FUNCTION : shortcut_connection_PROC
  1171.  
  1172.   PURPOSE  : callback function, which creates links between planes (see docu)
  1173.  
  1174.   NOTES    : 
  1175.   RETURNS  :
  1176.  
  1177.   UPDATE   : 20.12.1991
  1178. ******************************************************************************/
  1179.  
  1180. static void shortcut_connection_PROC(void)
  1181.  
  1182. {
  1183.  while(LINK_length) {
  1184.    delete_current_link();
  1185.  }
  1186.  if(shortcut_connection()) {
  1187.    write_current_link();
  1188.  }
  1189. }
  1190.  
  1191. /*****************************************************************************
  1192.   FUNCTION : overwrite_link_PROC
  1193.  
  1194.   PURPOSE  : callback function, which overwrites the current link element
  1195.              (Current Link) with the datas of the link editor (Edit Link).
  1196.  
  1197.   NOTES    : 
  1198.   RETURNS  :
  1199.  
  1200.   UPDATE   : 20.12.1991
  1201. ******************************************************************************/
  1202.  
  1203. static void overwrite_link_PROC(void)
  1204.  
  1205. {
  1206.  if(read_link_elements()) {
  1207.   overwrite_link();
  1208.   write_current_link();
  1209.   clear_edit_link();
  1210.  }
  1211. }
  1212.  
  1213. /*****************************************************************************
  1214.   FUNCTION : delete_link_PROC
  1215.  
  1216.   PURPOSE  : callback function, which deletes the Currenrt Link out of
  1217.              the link list.
  1218.  
  1219.   NOTES    : 
  1220.   RETURNS  :
  1221.  
  1222.   UPDATE   : 20.12.1991
  1223. ******************************************************************************/
  1224.  
  1225. static void delete_link_PROC(void)
  1226.  
  1227. {
  1228.  delete_current_link();
  1229.  if(LINK_length == 0) {
  1230.    clear_current_link();
  1231.  }
  1232.  else {
  1233.    write_current_link();
  1234.  }
  1235. }
  1236.  
  1237. /*****************************************************************************
  1238.   FUNCTION : forward_link_PROC
  1239.  
  1240.   PURPOSE  : callback function, which moves forward one list element in the
  1241.              link list.
  1242.  
  1243.   NOTES    : 
  1244.   RETURNS  :
  1245.  
  1246.   UPDATE   : 20.12.1991
  1247. ******************************************************************************/
  1248.  
  1249. static void forward_link_PROC(void)
  1250.  
  1251. {
  1252.  if(forward_link()){
  1253.    write_current_link();
  1254.  }
  1255. }
  1256.  
  1257. /*****************************************************************************
  1258.   FUNCTION : backward_link_PROC
  1259.  
  1260.   PURPOSE  : callback function, which moves backward one list element in the
  1261.              link list.
  1262.  
  1263.   NOTES    : 
  1264.   RETURNS  :
  1265.  
  1266.   UPDATE   : 20.12.1991
  1267. ******************************************************************************/
  1268.  
  1269. static void backward_link_PROC(void)
  1270.  
  1271. {
  1272.  if(backward_link()) {
  1273.    write_current_link();
  1274.  }
  1275. }
  1276.  
  1277. /*****************************************************************************
  1278.   FUNCTION : end_link_PROC
  1279.  
  1280.   PURPOSE  : callback function, which jumps to the end of the link list.
  1281.  
  1282.   NOTES    : 
  1283.   RETURNS  :
  1284.  
  1285.   UPDATE   : 20.12.1991
  1286. ******************************************************************************/
  1287.  
  1288. static void end_link_PROC(void)
  1289.  
  1290. {
  1291.  if(end_link()) {
  1292.    write_current_link();
  1293.  }
  1294. }
  1295.  
  1296. /*****************************************************************************
  1297.   FUNCNCTION : beginning_link_PROC
  1298.  
  1299.   PURPOSE  : callback function, which jumps to the beginning of the link list.
  1300.  
  1301.   NOTES    : 
  1302.   RETURNS  :
  1303.  
  1304.   UPDATE   : 20.12.1991
  1305. ******************************************************************************/
  1306.  
  1307. static void beginning_link_PROC(void)
  1308.  
  1309. {
  1310.  if(beginning_link()) {
  1311.    write_current_link();
  1312.  }
  1313. }
  1314.  
  1315. /*****************************************************************************
  1316.   FUNCNCTION : current_link_to_editor_PROC
  1317.  
  1318.   PURPOSE  : callback function, which writes the Current Link to Edit Link
  1319.  
  1320.   NOTES    : 
  1321.   RETURNS  :
  1322.  
  1323.   UPDATE   : 20.12.1991
  1324. ******************************************************************************/
  1325.  
  1326. static void current_link_to_editor_PROC(void)
  1327.  
  1328. {
  1329.  if(LINK_length != 0) {
  1330.    write_current_link_to_editor();
  1331.  }
  1332.  else {
  1333.    clear_edit_link();
  1334.  }
  1335. }
  1336.  
  1337. /*****************************************************************************
  1338.   FUNCNCTION : correct_link_input
  1339.  
  1340.   PURPOSE  : tests whether the input datas of Edit Link are correct and decides
  1341.              what kind of link (PLANE_TO_PLANE, PLANE_TO_LINK...) we have.
  1342.  
  1343.   NOTES    : 
  1344.   RETURNS  : Correct = 1 ; ERROR = 0
  1345.  
  1346.   UPDATE   : 20.12.1991
  1347. ******************************************************************************/
  1348.  
  1349. static int correct_link_input(void)
  1350.  
  1351. {
  1352.  PLANE *PLANE_source_no,*PLANE_target_no;
  1353.  
  1354.  int link_type;
  1355.  int target_plane=0,source_plane=0;
  1356.  int target_cluster=0,source_cluster=0;
  1357.  int target_unit=0,source_unit=0;
  1358.  int a,b,c,d;
  1359.  
  1360.  PLANE_source_no = get_plane(LINK_source_plane);
  1361.  PLANE_target_no = get_plane(LINK_target_plane);
  1362.  
  1363.  LINK_move = 0;
  1364.  
  1365.  if((PLANE_source_no != PLANE_target_no) &&
  1366.  
  1367.      PLANE_source_no != NULL &&
  1368.      PLANE_target_no != NULL &&
  1369.  
  1370.     (LINK_source_cluster_x + LINK_source_cluster_width  <= (*PLANE_source_no).width + 1) &&
  1371.     (LINK_source_cluster_y + LINK_source_cluster_height <= (*PLANE_source_no).height + 1) &&
  1372.     (LINK_source_unit_x <= (*PLANE_source_no).width) &&
  1373.     (LINK_source_unit_y <= (*PLANE_source_no).height) &&
  1374.     
  1375.     (LINK_target_cluster_x + LINK_target_cluster_width  <= (*PLANE_target_no).width + 1) &&
  1376.     (LINK_target_cluster_y + LINK_target_cluster_height <= (*PLANE_target_no).height + 1) &&
  1377.     (LINK_target_unit_x <= (*PLANE_target_no).width) &&
  1378.     (LINK_target_unit_y <= (*PLANE_target_no).height)) {
  1379.    
  1380.    target_plane = TARGET_PLANE;
  1381.    source_plane = SOURCE_PLANE;
  1382.  
  1383.    a=b=c=d=0;
  1384.  
  1385.    if(((a=LINK_source_cluster_x) >= 1) &&
  1386.       ((b=LINK_source_cluster_y) >= 1) &&
  1387.       ((c=LINK_source_cluster_width) >= 1) &&
  1388.       ((d=LINK_source_cluster_height) >= 1)) {
  1389.      source_cluster = SOURCE_CLUSTER;
  1390.    }
  1391.  
  1392.    if((! source_cluster) && a+b+c+d) {
  1393.       return 0;
  1394.     }
  1395.  
  1396.    a=b=0;
  1397.  
  1398.    if(((a=LINK_source_unit_x) >= 1) &&
  1399.       ((b=LINK_source_unit_y) >= 1)) {
  1400.      source_unit = SOURCE_UNIT;
  1401.    }
  1402.  
  1403.    if((! source_unit) && a+b) {
  1404.       return 0;
  1405.     }
  1406.  
  1407.    a=b=c=d=0;
  1408.  
  1409.    if(((a=LINK_target_cluster_x) >= 1) &&
  1410.       ((b=LINK_target_cluster_y) >= 1) &&
  1411.       ((c=LINK_target_cluster_width) >= 1) &&
  1412.       ((d=LINK_target_cluster_height) >= 1)) {
  1413.      target_cluster = TARGET_CLUSTER;
  1414.    }
  1415.  
  1416.    if((! target_cluster) && a+b+c+d) {
  1417.       return 0;
  1418.     }
  1419.  
  1420.    a=b=0;
  1421.  
  1422.    if(((a=LINK_target_unit_x) >= 1) &&
  1423.       ((b=LINK_target_unit_y) >= 1)) {
  1424.      target_unit = TARGET_UNIT;
  1425.    }
  1426.  
  1427.    if((! target_unit) && a+b) {
  1428.       return 0;
  1429.     }
  1430.  
  1431.    link_type =  target_plane+source_plane+target_cluster+source_cluster+target_unit+source_unit;
  1432.  
  1433.    if((link_type == PLANE_TO_PLANE) ||
  1434.       (link_type == PLANE_TO_CLUSTER) ||
  1435.       (link_type == PLANE_TO_UNIT) ||
  1436.       (link_type == CLUSTER_TO_PLANE) ||
  1437.       (link_type == CLUSTER_TO_CLUSTER) ||
  1438.       (link_type == CLUSTER_TO_UNIT) ||
  1439.       (link_type == UNIT_TO_PLANE) ||
  1440.       (link_type == UNIT_TO_CLUSTER) ||
  1441.       (link_type == UNIT_TO_UNIT)) {
  1442.  
  1443.       LINK_type_of_connection = link_type;
  1444.  
  1445.       if((LINK_source_move_delta_x || LINK_source_move_delta_y ||
  1446.          LINK_target_move_delta_x || LINK_target_move_delta_y) &&
  1447.          ((link_type == CLUSTER_TO_CLUSTER) ||
  1448.           (link_type == CLUSTER_TO_UNIT)    ||
  1449.           (link_type == UNIT_TO_CLUSTER)    ||
  1450.           (link_type == UNIT_TO_UNIT))) {
  1451.         LINK_move = 1;
  1452.       }
  1453.       else {
  1454.         LINK_source_move_delta_x = LINK_source_move_delta_y = LINK_target_move_delta_x = LINK_target_move_delta_y = 0;
  1455.       }
  1456.       return 1;
  1457.     }/* if */
  1458.  }
  1459.  return 0;
  1460. }
  1461.  
  1462.  
  1463. /*****************************************************************************
  1464.   FUNCTION : enter_link
  1465.  
  1466.   PURPOSE  : enters a link element at the end of the link list.
  1467.  
  1468.   NOTES    : 
  1469.   RETURNS  :
  1470.  
  1471.   UPDATE   : 20.12.1991
  1472. ******************************************************************************/
  1473.  
  1474. static void enter_link(void)
  1475.  
  1476. {
  1477.  LINK *LINK_element;
  1478.  
  1479.  LINK_element = (LINK *)malloc(sizeof(LINK)); 
  1480.  
  1481.  (*LINK_element).SOURCE.plane          = LINK_source_plane;
  1482.  (*LINK_element).SOURCE.CLUSTER.x      = LINK_source_cluster_x;
  1483.  (*LINK_element).SOURCE.CLUSTER.y      = LINK_source_cluster_y;
  1484.  (*LINK_element).SOURCE.CLUSTER.width  = LINK_source_cluster_width;
  1485.  (*LINK_element).SOURCE.CLUSTER.height = LINK_source_cluster_height;
  1486.  (*LINK_element).SOURCE.UNIT.x         = LINK_source_unit_x;
  1487.  (*LINK_element).SOURCE.UNIT.y         = LINK_source_unit_y;
  1488.  (*LINK_element).SOURCE.MOVE.delta_x   = LINK_source_move_delta_x;
  1489.  (*LINK_element).SOURCE.MOVE.delta_y   = LINK_source_move_delta_y;
  1490.  
  1491.  (*LINK_element).TARGET.plane          = LINK_target_plane;
  1492.  (*LINK_element).TARGET.CLUSTER.x      = LINK_target_cluster_x;
  1493.  (*LINK_element).TARGET.CLUSTER.y      = LINK_target_cluster_y;
  1494.  (*LINK_element).TARGET.CLUSTER.width  = LINK_target_cluster_width;
  1495.  (*LINK_element).TARGET.CLUSTER.height = LINK_target_cluster_height;
  1496.  (*LINK_element).TARGET.UNIT.x         = LINK_target_unit_x;
  1497.  (*LINK_element).TARGET.UNIT.y         = LINK_target_unit_y;
  1498.  (*LINK_element).TARGET.MOVE.delta_x   = LINK_target_move_delta_x;
  1499.  (*LINK_element).TARGET.MOVE.delta_y   = LINK_target_move_delta_y;
  1500.  
  1501.  (*LINK_element).move                  = LINK_move;
  1502.  (*LINK_element).type_of_connection    = LINK_type_of_connection;
  1503.  
  1504.  (*LINK_element).next   = NULL;
  1505.  (*LINK_element).before = LINK_last_element;
  1506.    
  1507.  if(LINK_last_element != NULL) {
  1508.    (*LINK_last_element).next = LINK_element;
  1509.  }
  1510.  
  1511.  if(LINK_first_element == NULL) {
  1512.    LINK_first_element = LINK_element;
  1513.  }
  1514.  
  1515.  LINK_last_element = LINK_element;
  1516.  LINK_current_element = LINK_last_element;
  1517.    
  1518.  LINK_length++;
  1519. }/* enter_link */
  1520.  
  1521. /*****************************************************************************
  1522.   FUNCTION : full_connection
  1523.  
  1524.   PURPOSE  : creates links between planes (see docu).
  1525.  
  1526.   NOTES    : 
  1527.   RETURNS  : Error = 0 ; Succes = 1
  1528.  
  1529.   UPDATE   : 20.12.1991
  1530. ******************************************************************************/
  1531.  
  1532. static int full_connection(void)
  1533.  
  1534. {
  1535.  PLANE *PLANE_element;
  1536.  
  1537.  if(PLANE_length >= 2) { 
  1538.  
  1539.    PLANE_element = (*PLANE_first_element).next;
  1540.  
  1541.    LINK_source_plane = 0;
  1542.    LINK_target_plane = 1;
  1543.    
  1544.    LINK_source_cluster_x =  LINK_source_cluster_y = LINK_source_cluster_width = LINK_source_cluster_height = 0;
  1545.    LINK_source_unit_x = LINK_source_unit_y = 0;
  1546.    LINK_source_move_delta_x = LINK_source_move_delta_y = 0;
  1547.  
  1548.    LINK_target_cluster_x = LINK_target_cluster_y = LINK_target_cluster_width = LINK_target_cluster_height = 0;
  1549.    LINK_target_unit_x = LINK_target_unit_y = 0;
  1550.    LINK_target_move_delta_x = LINK_target_move_delta_y = 0;
  1551.  
  1552.    LINK_move = 0;
  1553.    LINK_type_of_connection = PLANE_TO_PLANE;
  1554.  
  1555.    while(PLANE_element != NULL) {
  1556.  
  1557.      LINK_source_plane++;
  1558.      LINK_target_plane++;
  1559.      enter_link();
  1560.  
  1561.      PLANE_element = (*PLANE_element).next;
  1562.    }
  1563.    return 1;
  1564.  }
  1565.  return 0;
  1566. }
  1567.  
  1568. /*****************************************************************************
  1569.   FUNCTION : shortcut_connection
  1570.  
  1571.   PURPOSE  : creates links between planes(see docu).
  1572.  
  1573.   NOTES    : 
  1574.   RETURNS  : Error = 0 ; Succes = 1
  1575.  
  1576.   UPDATE   : 20.12.1991
  1577. ******************************************************************************/
  1578.  
  1579. static int shortcut_connection(void)
  1580.  
  1581. {
  1582.  PLANE *PLANE_source_element,*PLANE_target_element;
  1583.  
  1584.  if(PLANE_length >= 2) { 
  1585.  
  1586.    PLANE_source_element = (*PLANE_first_element).next;
  1587.    PLANE_target_element = PLANE_source_element;
  1588.  
  1589.    LINK_source_plane = 0;
  1590.    
  1591.    LINK_source_cluster_x =  LINK_source_cluster_y = LINK_source_cluster_width = LINK_source_cluster_height = 0;
  1592.    LINK_source_unit_x = LINK_source_unit_y = 0;
  1593.    LINK_source_move_delta_x = LINK_source_move_delta_y = 0;
  1594.  
  1595.    LINK_target_cluster_x = LINK_target_cluster_y = LINK_target_cluster_width = LINK_target_cluster_height = 0;
  1596.    LINK_target_unit_x = LINK_target_unit_y = 0;
  1597.    LINK_target_move_delta_x = LINK_target_move_delta_y = 0;
  1598.  
  1599.    LINK_move = 0;
  1600.    LINK_type_of_connection = PLANE_TO_PLANE;
  1601.  
  1602.    while(PLANE_source_element != NULL){
  1603.      LINK_source_plane++;
  1604.      LINK_target_plane = LINK_source_plane;
  1605.      while(PLANE_target_element != NULL) {
  1606.        LINK_target_plane++;
  1607.        enter_link();
  1608.        PLANE_target_element = (*PLANE_target_element).next;
  1609.      }
  1610.      PLANE_source_element = (*PLANE_source_element).next;
  1611.      PLANE_target_element = PLANE_source_element;
  1612.    }
  1613.    return 1;
  1614.  }
  1615.  return 0;
  1616. }
  1617.  
  1618. /*****************************************************************************
  1619.   FUNCTION : overwrite_link
  1620.  
  1621.   PURPOSE  : overwrites the current link element (Current Link) with the 
  1622.              datas of the link editor (Edit Link).
  1623.  
  1624.   NOTES    : 
  1625.   RETURNS  :
  1626.  
  1627.   UPDATE   : 20.12.1991
  1628. ******************************************************************************/
  1629.  
  1630. static void overwrite_link(void)
  1631.  
  1632. {
  1633.  if(LINK_length == 0) {
  1634.    enter_link();
  1635.  }
  1636.  else {
  1637.    (*LINK_current_element).SOURCE.plane          = LINK_source_plane;
  1638.    (*LINK_current_element).SOURCE.CLUSTER.x      = LINK_source_cluster_x;
  1639.    (*LINK_current_element).SOURCE.CLUSTER.y      = LINK_source_cluster_y;
  1640.    (*LINK_current_element).SOURCE.CLUSTER.width  = LINK_source_cluster_width;
  1641.    (*LINK_current_element).SOURCE.CLUSTER.height = LINK_source_cluster_height;
  1642.    (*LINK_current_element).SOURCE.UNIT.x         = LINK_source_unit_x;
  1643.    (*LINK_current_element).SOURCE.UNIT.y         = LINK_source_unit_y;
  1644.    (*LINK_current_element).SOURCE.MOVE.delta_x   = LINK_source_move_delta_x;
  1645.    (*LINK_current_element).SOURCE.MOVE.delta_y   = LINK_source_move_delta_y;
  1646.   
  1647.    (*LINK_current_element).TARGET.plane          = LINK_target_plane;
  1648.    (*LINK_current_element).TARGET.CLUSTER.x      = LINK_target_cluster_x;
  1649.    (*LINK_current_element).TARGET.CLUSTER.y      = LINK_target_cluster_y;
  1650.    (*LINK_current_element).TARGET.CLUSTER.width  = LINK_target_cluster_width;
  1651.    (*LINK_current_element).TARGET.CLUSTER.height = LINK_target_cluster_height;
  1652.    (*LINK_current_element).TARGET.UNIT.x         = LINK_target_unit_x;
  1653.    (*LINK_current_element).TARGET.UNIT.y         = LINK_target_unit_y;
  1654.    (*LINK_current_element).TARGET.MOVE.delta_x   = LINK_target_move_delta_x;
  1655.    (*LINK_current_element).TARGET.MOVE.delta_y   = LINK_target_move_delta_y;
  1656.  
  1657.    (*LINK_current_element).move                  = LINK_move;
  1658.    (*LINK_current_element).type_of_connection    = LINK_type_of_connection;
  1659.  
  1660.  
  1661.  }/* if */
  1662. }/* overwrite_link */
  1663.  
  1664.  
  1665. /*****************************************************************************
  1666.   FUNCTION : delete_current_link
  1667.  
  1668.   PURPOSE  : deletes  Currenrt Link out of the link list.
  1669.  
  1670.   NOTES    : 
  1671.   RETURNS  :
  1672.  
  1673.   UPDATE   : 20.12.1991
  1674. ******************************************************************************/
  1675.  
  1676. static void delete_current_link(void)
  1677.  
  1678. {
  1679.  LINK *LINK_element;
  1680.  
  1681.  LINK_element = LINK_current_element;
  1682.  
  1683.  /* Delete the element "LINK_element" out of the plane-list */
  1684.  
  1685.  if(LINK_length != 0) {
  1686.    if((*LINK_element).before != NULL) {
  1687.      (*(*LINK_element).before).next = (*LINK_element).next;
  1688.    }
  1689.    if((*LINK_element).next != NULL) {
  1690.      (*(*LINK_element).next).before = (*LINK_element).before;
  1691.    }
  1692.  
  1693.    LINK_length--;
  1694.  
  1695.    /* Update the three pointers 
  1696.                   LINK_current_element,
  1697.                   LINK_first_element,
  1698.                   LINK_last_element.
  1699.    */
  1700.  
  1701.    if(LINK_length == 0){
  1702.      LINK_current_element = NULL;
  1703.      LINK_first_element   = NULL;
  1704.      LINK_last_element    = NULL;
  1705.    }
  1706.    else if((*LINK_element).next == NULL) {
  1707.      LINK_current_element = (*LINK_element).before;
  1708.      LINK_last_element    = LINK_current_element;
  1709.    }
  1710.    else if((*LINK_element).before == NULL) {
  1711.      LINK_current_element = (*LINK_element).next;
  1712.      LINK_first_element   = LINK_current_element;
  1713.    }
  1714.    else {
  1715.      LINK_current_element = (*LINK_element).next;
  1716.    }  
  1717.  
  1718.    free(LINK_element);
  1719.  }
  1720. }
  1721.  
  1722. /*****************************************************************************
  1723.   FUNCTION : get_links_and_delete_them(plane_no)
  1724.  
  1725.   PURPOSE  : deletes all the links which are connected with the plane 
  1726.              "plane_no"
  1727.  
  1728.   NOTES    : 
  1729.   RETURNS  :
  1730.  
  1731.   UPDATE   : 20.12.1991
  1732. ******************************************************************************/
  1733.  
  1734. static void get_links_and_delete_them(int plane_no)
  1735.  
  1736. {
  1737.  LINK *LINK_element = LINK_first_element;
  1738.  
  1739.  while(LINK_element != NULL) {
  1740.    if(((*LINK_element).SOURCE.plane != plane_no) &&
  1741.       ((*LINK_element).TARGET.plane != plane_no)) {
  1742.      LINK_element = (*LINK_element).next;
  1743.    }
  1744.    else {
  1745.      LINK_current_element = LINK_element;
  1746.      LINK_element = (*LINK_element).next;
  1747.      delete_current_link();
  1748.    }
  1749.  }/* while */
  1750. }
  1751.  
  1752.  
  1753. /*****************************************************************************
  1754.   FUNCTION : forward_link
  1755.  
  1756.   PURPOSE  : moves forward one list element in the link list.
  1757.  
  1758.   NOTES    : 
  1759.   RETURNS  :  Error = 0 ; Succes = 1
  1760.  
  1761.   UPDATE   : 20.12.1991
  1762. ******************************************************************************/
  1763.  
  1764. static int forward_link(void)
  1765.  
  1766. {
  1767.  if(LINK_length != 0) {
  1768.    if((*LINK_current_element).next != NULL) {
  1769.      LINK_current_element = (*LINK_current_element).next;
  1770.    }
  1771.    return 1;
  1772.  }
  1773.  return 0;
  1774. }
  1775.  
  1776. /*****************************************************************************
  1777.   FUNCTION : backward_link
  1778.  
  1779.   PURPOSE  : moves backward one list element in the link list.
  1780.   NOTES    : 
  1781.   RETURNS  : Error = 0 ; Succes = 1
  1782.  
  1783.   UPDATE   : 20.12.1991
  1784. ******************************************************************************/
  1785.  
  1786. static int backward_link(void)
  1787.  
  1788. {
  1789.  if(LINK_length != 0) {
  1790.    if((*LINK_current_element).before != NULL) {
  1791.      LINK_current_element = (*LINK_current_element).before;
  1792.    }
  1793.    return 1;
  1794.  }
  1795.  return 0;
  1796. }
  1797.  
  1798. /*****************************************************************************
  1799.   FUNCTION : beginning_link
  1800.  
  1801.   PURPOSE  : jumps to the beginning of the link list.
  1802.  
  1803.   NOTES    : 
  1804.   RETURNS  : Error = 0 ; Succes = 1
  1805.  
  1806.   UPDATE   : 20.12.1991
  1807. ******************************************************************************/
  1808.  
  1809. static int beginning_link(void)
  1810.  
  1811. {
  1812.  if(LINK_length != 0){
  1813.    LINK_current_element = LINK_first_element;
  1814.    return 1;
  1815.  }
  1816.  return 0;
  1817. }
  1818.  
  1819. /*****************************************************************************
  1820.   FUNCTION : end_link
  1821.  
  1822.   PURPOSE  : jumps to the end of the link list.
  1823.   NOTES    : 
  1824.   RETURNS  : Error = 0 ; Succes = 1
  1825.  
  1826.   UPDATE   : 20.12.1991
  1827. ******************************************************************************/
  1828.  
  1829. static int end_link(void)
  1830.  
  1831. {
  1832.  if(LINK_length != 0) {
  1833.    LINK_current_element = LINK_last_element;
  1834.    return 1;
  1835.  }
  1836.  return 0;
  1837. }
  1838.  
  1839. /*****************************************************************************
  1840.  
  1841.   bn_plane
  1842.   PURPOSE  : Functions of the plane editor.
  1843.  
  1844. ******************************************************************************/
  1845.  
  1846.  
  1847. /*****************************************************************************
  1848.   FUNCTION : read_plane_elements
  1849.  
  1850.   PURPOSE  : reads the input datas of the plane editor (Edit Plane).
  1851.  
  1852.   NOTES    : 
  1853.   RETURNS  :  Error = 0 ; Succes = 1
  1854.  
  1855.   UPDATE   : 20.12.1991
  1856. ******************************************************************************/
  1857.  
  1858. static int read_plane_elements(void)
  1859.  
  1860. {
  1861.  PLANE_width = ui_xIntFromAsciiWidget(z4s3);
  1862.  PLANE_height = ui_xIntFromAsciiWidget(z5s3);
  1863.  if((PLANE_width > 0) && (PLANE_height > 0)) {
  1864.    return 1;
  1865.  }
  1866.  else {
  1867.    return 0;
  1868.  }
  1869. }
  1870.   
  1871. /*****************************************************************************
  1872.   FUNCTION : write_current_plane
  1873.  
  1874.   PURPOSE  : writes the datas of the current_element to the control part 
  1875.              (Current Plane) of the plane editor.
  1876.  
  1877.   NOTES    : 
  1878.   RETURNS  : 
  1879.  
  1880.   UPDATE   : 20.12.1991
  1881. ******************************************************************************/
  1882.  
  1883. static void write_current_plane(void)
  1884.  
  1885.  {
  1886.   char buf[10];
  1887.  
  1888.   sprintf(buf,"%d",PLANE_no);
  1889.   ui_xSetLabel(z2s2,bn_widget_output(buf));
  1890.   ui_xSetLabel(z3s2,plane_type[(*PLANE_current_element).type]);
  1891.   sprintf(buf,"%d",(*PLANE_current_element).width);
  1892.   ui_xSetLabel(z4s2,bn_widget_output(buf));
  1893.   sprintf(buf,"%d",(*PLANE_current_element).height);
  1894.   ui_xSetLabel(z5s2,bn_widget_output(buf));
  1895.   sprintf(buf,"%d",0);
  1896.   ui_xSetLabel(z6s2,bn_widget_output(buf));
  1897.   ui_xSetLabel(z7s2,plane_pos[(*PLANE_current_element).pos]);
  1898. }
  1899.  
  1900. /*****************************************************************************
  1901.   FUNCTION : clear_current_plane
  1902.  
  1903.   PURPOSE  : Deletes the datas standing in Current Plane.
  1904.  
  1905.   NOTES    : 
  1906.   RETURNS  :
  1907.  
  1908.   UPDATE   : 20.12.1991
  1909. ******************************************************************************/
  1910.  
  1911. static void clear_current_plane(void)
  1912.  
  1913.  {
  1914.   ui_xSetLabel(z2s2,"");
  1915.   ui_xSetLabel(z3s2,"");
  1916.   ui_xSetLabel(z4s2,"");
  1917.   ui_xSetLabel(z5s2,"");
  1918.   ui_xSetLabel(z6s2,"");
  1919.   ui_xSetLabel(z7s2,"");
  1920. }
  1921.  
  1922. /*****************************************************************************
  1923.   FUNCTION : write_current_plane_to_editor
  1924.  
  1925.   PURPOSE  : writes the datas of Current Plane to Edit Plane
  1926.  
  1927.   NOTES    : 
  1928.   RETURNS  :
  1929.  
  1930.   UPDATE   : 20.12.1991
  1931. ******************************************************************************/
  1932.  
  1933. static void write_current_plane_to_editor(void)
  1934.  
  1935.  {
  1936.   char buf[10];
  1937.  
  1938.   PLANE_type = (*PLANE_current_element).type;
  1939.   ui_xSetLabel(z3s3,plane_type[PLANE_type]);
  1940.   sprintf(buf,"%d",(*PLANE_current_element).width);
  1941.   ui_xSetString(z4s3,bn_widget_output(buf));
  1942.   sprintf(buf,"%d",(*PLANE_current_element).height);
  1943.   ui_xSetString(z5s3,bn_widget_output(buf));
  1944.   sprintf(buf,"%d",0);
  1945.   ui_xSetString(z6s3,bn_widget_output(buf));
  1946.   PLANE_pos = (*PLANE_current_element).pos;
  1947.   ui_xSetLabel(z7s3,plane_pos[PLANE_pos]);
  1948. }
  1949.  
  1950. /*****************************************************************************
  1951.   FUNCTION : clear_edit_plane
  1952.  
  1953.   PURPOSE  : Deletes the datas standing in Edit Link.
  1954.  
  1955.   NOTES    : 
  1956.   RETURNS  :
  1957.  
  1958.   UPDATE   : 20.12.1991
  1959. ******************************************************************************/
  1960.  
  1961. static void clear_edit_plane(void)
  1962.  
  1963. {
  1964.  ui_xSetString(z4s3,"");
  1965.  ui_xSetString(z5s3,"");
  1966.  ui_xSetString(z6s3,"");
  1967.  
  1968.  
  1969. /*****************************************************************************
  1970.   FUNCTION : cancel_net_PROC
  1971.  
  1972.   PURPOSE  : callback function, which deletes all the datas in the link 
  1973.              editor and in the plane editor.
  1974.  
  1975.   NOTES    : 
  1976.   RETURNS  :
  1977.  
  1978.   UPDATE   : 20.12.1991
  1979. ******************************************************************************/
  1980.  
  1981. static void cancel_net_PROC(void)
  1982.  
  1983. {
  1984.  while(PLANE_length){
  1985.   delete_current_plane();
  1986.  }
  1987.  clear_current_plane();
  1988.  clear_current_link();
  1989. }
  1990.  
  1991. /*****************************************************************************
  1992.   FUNCTION : enter_plane_PROC
  1993.  
  1994.   PURPOSE  : callback function, which enters a plane element at the end of the 
  1995.              plane list.
  1996.  
  1997.   NOTES    : the plane list contains all datas entered by the plane editor.
  1998.              Every plane element is a struct (see bn_types.c)
  1999.   RETURNS  :
  2000.  
  2001.   UPDATE   : 20.12.1991
  2002. ******************************************************************************/
  2003.  
  2004. static void enter_plane_PROC(void)
  2005.  
  2006. {
  2007.  if(read_plane_elements()){
  2008.    enter_plane();
  2009.    write_current_plane();
  2010.    clear_edit_plane();
  2011.  }
  2012. }
  2013.  
  2014. /*****************************************************************************
  2015.   FUNCTION : insert_plane_PROC
  2016.  
  2017.   PURPOSE  : callback function, which inserts the the input datas of the
  2018.              plane editor (Edit Plane) in front of Current Plane.
  2019.  
  2020.   NOTES    : 
  2021.   RETURNS  :
  2022.  
  2023.   UPDATE   : 20.12.1991
  2024. ******************************************************************************/
  2025.  
  2026. static void insert_plane_PROC(void)
  2027.  
  2028. {
  2029.  if(read_plane_elements()) {
  2030.    insert_plane();
  2031.    write_current_plane();
  2032.    clear_edit_plane();
  2033.    if(LINK_length == 0) {
  2034.      clear_current_link();
  2035.    }
  2036.    else {
  2037.      write_current_link();
  2038.    }
  2039.  }
  2040. }
  2041.  
  2042. /*****************************************************************************
  2043.   FUNCTION : overwrite_plane_PROC
  2044.  
  2045.   PURPOSE  : callback function, which overwrites the current plane element
  2046.              (Current Plane) with the datas of the plane editor (Edit plane).
  2047.  
  2048.   NOTES    : 
  2049.   RETURNS  :
  2050.  
  2051.   UPDATE   : 20.12.1991
  2052. ******************************************************************************/
  2053.  
  2054. static void overwrite_plane_PROC(void)
  2055.  
  2056. {
  2057.  if(read_plane_elements()) {
  2058.   overwrite_plane();
  2059.   write_current_plane();
  2060.   clear_edit_plane();
  2061.   if(LINK_length == 0) {
  2062.     clear_current_link();
  2063.   }
  2064.   else {
  2065.     write_current_link();
  2066.   }
  2067.  }
  2068. }
  2069.  
  2070. /*****************************************************************************
  2071.   FUNCTION : delete_plane_PROC
  2072.  
  2073.   PURPOSE  : callback function, which deletes the Currenrt Plane out of
  2074.              the plane list.
  2075.  
  2076.   NOTES    : 
  2077.   RETURNS  :
  2078.  
  2079.   UPDATE   : 20.12.1991
  2080. ******************************************************************************/
  2081.  
  2082. static void delete_plane_PROC(void)
  2083.  
  2084. {
  2085.  delete_current_plane();
  2086.  if(PLANE_length == 0) {
  2087.    clear_current_plane();
  2088.  }
  2089.  else {
  2090.    write_current_plane();
  2091.  }
  2092.  if(LINK_length == 0) {
  2093.    clear_current_link();
  2094.  }
  2095.  else {
  2096.   write_current_link();
  2097.  }
  2098. }
  2099.  
  2100. /*****************************************************************************
  2101.   FUNCTION : forward_plane_PROC
  2102.  
  2103.   PURPOSE  : callback function, which moves forward one list element in the
  2104.              plane list.
  2105.  
  2106.   NOTES    : 
  2107.   RETURNS  :
  2108.  
  2109.   UPDATE   : 20.12.1991
  2110. ******************************************************************************/
  2111.  
  2112. static void forward_plane_PROC(void)
  2113.  
  2114. {
  2115.  if(forward_plane()){
  2116.    write_current_plane();
  2117.  }
  2118. }
  2119.  
  2120. /*****************************************************************************
  2121.   FUNCTION : backward_plane_PROC
  2122.  
  2123.   PURPOSE  : callback function, which moves backward one list element in the
  2124.              plane list.
  2125.  
  2126.   NOTES    : 
  2127.   RETURNS  :
  2128.  
  2129.   UPDATE   : 20.12.1991
  2130. ******************************************************************************/
  2131.  
  2132. static void backward_plane_PROC(void)
  2133.  
  2134. {
  2135.  if(backward_plane()) {
  2136.    write_current_plane();
  2137.  }
  2138. }
  2139.  
  2140. /*****************************************************************************
  2141.   FUNCTION : end_plane_PROC
  2142.  
  2143.   PURPOSE  : callback function, which jumps to the end of the plane list.
  2144.  
  2145.   NOTES    : 
  2146.   RETURNS  :
  2147.  
  2148.   UPDATE   : 20.12.1991
  2149. ******************************************************************************/
  2150.  
  2151. static void end_plane_PROC(void)
  2152.  
  2153. {
  2154.  if(end_plane()) {
  2155.    write_current_plane();
  2156.  }
  2157. }
  2158.  
  2159. /*****************************************************************************
  2160.   FUNCNCTION : beginning_plane_PROC
  2161.  
  2162.   PURPOSE  : callback function, which jumps to the beginning of the plane list.
  2163.  
  2164.   NOTES    : 
  2165.   RETURNS  :
  2166.  
  2167.   UPDATE   : 20.12.1991
  2168. ******************************************************************************/
  2169.  
  2170. static void beginning_plane_PROC(void)
  2171.  
  2172. {
  2173.  if(beginning_plane()) {
  2174.    write_current_plane();
  2175.  }
  2176. }
  2177.  
  2178. /*****************************************************************************
  2179.   FUNCNCTION : pos_PROC
  2180.  
  2181.   PURPOSE  : callback function, which defines the position of the plane in the
  2182.              display window.
  2183.  
  2184.   NOTES    : 
  2185.   RETURNS  :
  2186.  
  2187.   UPDATE   : 20.12.1991
  2188. ******************************************************************************/
  2189.  
  2190. static void pos_PROC(void)
  2191.  
  2192. {
  2193.  if(PLANE_pos == BN_RIGHT) {
  2194.    PLANE_pos = BN_BELOW;
  2195.  }
  2196.  else if(PLANE_pos == BN_BELOW) {
  2197.    PLANE_pos = BN_LEFT;
  2198.  } 
  2199.  else {
  2200.    PLANE_pos = BN_RIGHT;
  2201.  }
  2202.  ui_xSetLabel(z7s3,plane_pos[PLANE_pos]);
  2203. }
  2204.  
  2205. /*****************************************************************************
  2206.   FUNCNCTION : current_plane_to_editor_PROC
  2207.  
  2208.   PURPOSE  : callback function, which writes the Current Plane to Edit Plane
  2209.  
  2210.   NOTES    : 
  2211.   RETURNS  :
  2212.  
  2213.   UPDATE   : 20.12.1991
  2214. ******************************************************************************/
  2215.  
  2216. static void current_plane_to_editor_PROC(void)
  2217.  
  2218. {
  2219.  if(PLANE_length != 0) {
  2220.    write_current_plane_to_editor();
  2221.  }
  2222.  else {
  2223.    clear_edit_plane();
  2224.  }
  2225. }
  2226.  
  2227. /*****************************************************************************
  2228.   FUNCNCTION : type_PROC
  2229.  
  2230.   PURPOSE  : callback function, which defines the unit type of a plane.
  2231.  
  2232.   NOTES    : 
  2233.   RETURNS  :
  2234.  
  2235.   UPDATE   : 20.12.1991
  2236. ******************************************************************************/
  2237.  
  2238. static void type_PROC(void)
  2239.  
  2240. {
  2241.  switch(PLANE_type){
  2242.    case BN_INPUT : {PLANE_type = BN_HIDDEN; break;}
  2243.    case BN_HIDDEN: {PLANE_type = BN_OUTPUT; break;}
  2244.    case BN_OUTPUT: {PLANE_type = BN_INPUT ; break;}
  2245.  }
  2246.  ui_xSetLabel(z3s3,plane_type[PLANE_type]);
  2247. }
  2248.  
  2249. /*****************************************************************************
  2250.   FUNCTION : enter_plane
  2251.  
  2252.   PURPOSE  : enters a plane element at the end of the plane list.
  2253.  
  2254.   NOTES    : 
  2255.   RETURNS  :
  2256.  
  2257.   UPDATE   : 20.12.1991
  2258. ******************************************************************************/
  2259.  
  2260. static void enter_plane(void)
  2261.  
  2262. {
  2263.  PLANE *PLANE_element;
  2264.  
  2265.  PLANE_element = (PLANE *)malloc(sizeof(PLANE));
  2266.  (*PLANE_element).width      = PLANE_width;                                    
  2267.  (*PLANE_element).height      = PLANE_height;
  2268.  (*PLANE_element).pos    = PLANE_pos;
  2269.  (*PLANE_element).type   = PLANE_type;                                    
  2270.  (*PLANE_element).next   = NULL;                            
  2271.  (*PLANE_element).before = PLANE_last_element;         
  2272.  
  2273.  if(PLANE_last_element != NULL) {
  2274.    (*PLANE_last_element).next = PLANE_element;
  2275.  }
  2276.  
  2277.  if(PLANE_first_element == NULL) {
  2278.    PLANE_first_element = PLANE_element;
  2279.  }
  2280.  
  2281.  PLANE_last_element = PLANE_element;
  2282.  PLANE_current_element = PLANE_last_element;
  2283.  
  2284.  PLANE_no = ++PLANE_length;
  2285. }/* enter_plane */
  2286.  
  2287. /*****************************************************************************
  2288.   FUNCTION : insert_plane
  2289.  
  2290.   PURPOSE  : inserts the the input datas of the plane editor (Edit Plane) in 
  2291.              front of Current Plane.
  2292.  
  2293.   NOTES    : 
  2294.   RETURNS  :
  2295.  
  2296.   UPDATE   : 20.12.1991
  2297. ******************************************************************************/
  2298.  
  2299. static void insert_plane(void)
  2300.  
  2301. {
  2302.  PLANE *PLANE_element;
  2303.  
  2304.  if(PLANE_length == 0) {
  2305.    enter_plane();
  2306.  }
  2307.  else {
  2308.    PLANE_element = (PLANE *)malloc(sizeof(PLANE));
  2309.    
  2310.    (*PLANE_element).width      = PLANE_width;                                    
  2311.    (*PLANE_element).height      = PLANE_height;
  2312.    (*PLANE_element).pos    = PLANE_pos;
  2313.    (*PLANE_element).type   = PLANE_type;                                    
  2314.    (*PLANE_element).next   = PLANE_current_element;                            
  2315.    (*PLANE_element).before = (*PLANE_current_element).before;
  2316.  
  2317.    if((*PLANE_current_element).before != 0) {
  2318.      (*(*PLANE_current_element).before).next = PLANE_element;
  2319.    }
  2320.    (*PLANE_current_element).before = PLANE_element;         
  2321.  
  2322.    PLANE_current_element = PLANE_element;
  2323.    
  2324.    if((*PLANE_element).before == NULL) {
  2325.      PLANE_first_element = PLANE_element;
  2326.    } 
  2327.  
  2328.    PLANE_length++;
  2329.  
  2330.    LINK_current_element = LINK_first_element; 
  2331.  
  2332.    while(LINK_current_element) {
  2333.      if((*LINK_current_element).SOURCE.plane >= PLANE_no) {
  2334.        (*LINK_current_element).SOURCE.plane++;
  2335.      }
  2336.      if((*LINK_current_element).TARGET.plane >= PLANE_no) {
  2337.        (*LINK_current_element).TARGET.plane++;
  2338.      }
  2339.      LINK_current_element = (*LINK_current_element).next;
  2340.    }
  2341.  
  2342.    LINK_current_element = LINK_last_element;
  2343.  
  2344.  }
  2345. }
  2346.  
  2347. /*****************************************************************************
  2348.   FUNCTION : overwrite_plane
  2349.  
  2350.   PURPOSE  : overwrites the current plane element (Current Plane) with the 
  2351.              datas of the plane editor (Edit Plane).
  2352.  
  2353.   NOTES    : 
  2354.   RETURNS  :
  2355.  
  2356.   UPDATE   : 20.12.1991
  2357. ******************************************************************************/
  2358.  
  2359. static void overwrite_plane(void)
  2360.  
  2361. {
  2362.  if(PLANE_length == 0) {
  2363.    enter_plane();
  2364.  }
  2365.  else {
  2366.    (*PLANE_current_element).width = PLANE_width;
  2367.    (*PLANE_current_element).height = PLANE_height;
  2368.    (*PLANE_current_element).pos = PLANE_pos;
  2369.    (*PLANE_current_element).type = PLANE_type;
  2370.  
  2371.    get_links_and_delete_them(PLANE_no);
  2372.  
  2373.    LINK_current_element = LINK_first_element;
  2374.  
  2375.  }
  2376. }
  2377.  
  2378. /*****************************************************************************
  2379.   FUNCTION : delete_current_plane
  2380.  
  2381.   PURPOSE  : deletes Currenrt Plane out of the plane list.
  2382.  
  2383.   NOTES    : 
  2384.   RETURNS  :
  2385.  
  2386.   UPDATE   : 20.12.1991
  2387. ******************************************************************************/
  2388.  
  2389. static void delete_current_plane(void)
  2390.  
  2391. {
  2392.  PLANE *PLANE_element;
  2393.  
  2394.  PLANE_element = PLANE_current_element;
  2395.  
  2396.  /* Delete the element "PLANE_element" out of the plane-list */
  2397.  
  2398.  if(PLANE_length != 0) {
  2399.    if((*PLANE_element).before != NULL) {
  2400.      (*(*PLANE_element).before).next = (*PLANE_element).next;
  2401.    }
  2402.    if((*PLANE_element).next != NULL) {
  2403.      (*(*PLANE_element).next).before = (*PLANE_element).before;
  2404.    }
  2405.  
  2406.    /* Delete all the links which are connected with the deleted plane */
  2407.    
  2408.    get_links_and_delete_them(PLANE_no);
  2409.  
  2410.    LINK_current_element = LINK_first_element;
  2411.  
  2412.    /* Decrement the number of the Planes */
  2413.  
  2414.    while(LINK_current_element) {
  2415.      if((*LINK_current_element).SOURCE.plane > PLANE_no) {
  2416.        (*LINK_current_element).SOURCE.plane--;
  2417.      }
  2418.      if((*LINK_current_element).TARGET.plane > PLANE_no) {
  2419.        (*LINK_current_element).TARGET.plane--;
  2420.      }
  2421.      LINK_current_element = (*LINK_current_element).next;
  2422.    }
  2423.  
  2424.    LINK_current_element = LINK_last_element;
  2425.  
  2426.    PLANE_length--;
  2427.  
  2428.    /* Update the three pointers "PLANE_current_element", "PLANE_first_element"
  2429.       "PLANE_last_element."  */
  2430.  
  2431.    if(PLANE_length == 0){
  2432.      PLANE_current_element = NULL;
  2433.      PLANE_first_element   = NULL;
  2434.      PLANE_last_element    = NULL;
  2435.      PLANE_no--;
  2436.    }
  2437.    else if((*PLANE_element).next == NULL) {
  2438.      PLANE_current_element = (*PLANE_element).before;
  2439.      PLANE_last_element    = PLANE_current_element;
  2440.      PLANE_no--;
  2441.    }
  2442.    else if((*PLANE_element).before == NULL) {
  2443.      PLANE_current_element = (*PLANE_element).next;
  2444.      PLANE_first_element   = PLANE_current_element;
  2445.    }
  2446.    else {
  2447.      PLANE_current_element = (*PLANE_element).next;
  2448.    }
  2449.  
  2450.    free(PLANE_element);
  2451.  }
  2452. }
  2453.  
  2454. /*****************************************************************************
  2455.   FUNCTION : forward_plane
  2456.  
  2457.   PURPOSE  : moves forward one list element in the plane list.
  2458.  
  2459.   NOTES    : 
  2460.   RETURNS  : Error = 0 ; Succes = 1
  2461.  
  2462.   UPDATE   : 20.12.1991
  2463. ******************************************************************************/
  2464.  
  2465. static int forward_plane(void)
  2466.  
  2467. {
  2468.  if(PLANE_length != 0) {
  2469.    if((*PLANE_current_element).next != NULL) {
  2470.      PLANE_current_element = (*PLANE_current_element).next;
  2471.      PLANE_no++;
  2472.    }
  2473.    return 1;
  2474.  }
  2475.  else {
  2476.   return 0;
  2477.  }
  2478. }
  2479.  
  2480. /*****************************************************************************
  2481.   FUNCTION : backward_link
  2482.  
  2483.   PURPOSE  : moves backward one plane element in the link list.
  2484.  
  2485.   NOTES    : 
  2486.   RETURNS  : Error = 0 ; Succes = 1
  2487.  
  2488.   UPDATE   : 20.12.1991
  2489. ******************************************************************************/
  2490.  
  2491. static int backward_plane(void)
  2492.  
  2493. {
  2494.  if(PLANE_length != 0) {
  2495.    if((*PLANE_current_element).before != NULL) {
  2496.      PLANE_current_element = (*PLANE_current_element).before;
  2497.      PLANE_no--;
  2498.    }
  2499.    return 1;
  2500.  }
  2501.  else {
  2502.    return 0;
  2503.  }
  2504. }
  2505.  
  2506. /*****************************************************************************
  2507.   FUNCTION : beginning_plane
  2508.  
  2509.   PURPOSE  : jumps to the beginning of the plane list.
  2510.  
  2511.   NOTES    : 
  2512.   RETURNS  : Error = 0 ; Succes = 1
  2513.  
  2514.   UPDATE   : 20.12.1991
  2515. ******************************************************************************/
  2516.  
  2517. static int beginning_plane(void)
  2518.  
  2519. {
  2520.  if(PLANE_length != 0){
  2521.    PLANE_current_element = PLANE_first_element;
  2522.    PLANE_no = 1;
  2523.    return 1;
  2524.  }
  2525.  else {
  2526.   return 0;
  2527.  }
  2528. }
  2529.  
  2530. /*****************************************************************************
  2531.   FUNCTION : end_plane
  2532.  
  2533.   PURPOSE  : jumps to the end of the plane list.
  2534.  
  2535.   NOTES    : 
  2536.   RETURNS  : Error = 0 ; Succes = 1
  2537.  
  2538.   UPDATE   : 20.12.1991
  2539. ******************************************************************************/
  2540.  
  2541. static int end_plane(void)
  2542.  
  2543. {
  2544.  if(PLANE_length != 0) {
  2545.    PLANE_current_element = PLANE_last_element;
  2546.    PLANE_no = PLANE_length;
  2547.    return 1;
  2548.  }
  2549.  else {
  2550.    return 0;
  2551.  }
  2552. }
  2553.  
  2554. /*****************************************************************************
  2555.   FUNCTION : get_plane
  2556.  
  2557.   PURPOSE  : returns a pointer to the plane element "plane_no"
  2558.  
  2559.   NOTES    : 
  2560.   RETURNS  : returns a pointer to the plane element "plane_no" 
  2561.  
  2562.   UPDATE   : 20.12.1991
  2563. ******************************************************************************/
  2564.  
  2565. static PLANE *get_plane(int plane_no)
  2566.  
  2567. {
  2568.  PLANE *PLANE_element = PLANE_first_element;
  2569.  int counter = 1;
  2570.  
  2571.  while((PLANE_element != NULL) &&
  2572.        (counter != plane_no)) {
  2573.    counter++;
  2574.    PLANE_element = (*PLANE_element).next;
  2575.           
  2576.  }/*while*/
  2577.  return PLANE_element;
  2578. }/*get_plane*/
  2579.  
  2580.  
  2581. /*****************************************************************************
  2582.  
  2583. ******************************************************************************/
  2584.  
  2585. /* end of file */
  2586. /* lines: 2710 */
  2587.  
  2588.  
  2589.  
  2590.